int main(void) { int i; #define TEST_MATCH(frame_rate, code, ext_n, ext_d) do { \ AVRational fr = frame_rate; \ int c, n, d; \ ff_mpeg12_find_best_frame_rate(fr, &c, &n, &d, 0); \ if (c != code || n != ext_n || d != ext_d) { \ av_log(NULL, AV_LOG_ERROR, "Failed to match %d/%d: " \ "code = %d, ext_n = %d, ext_d = %d.\n", \ fr.num, fr.den, c, n, d); \ return 1; \ } \ } while (0) #define TEST_EXACT(frn, frd) do { \ AVRational fr = (AVRational) { frn, frd }; \ int c, n, d; \ ff_mpeg12_find_best_frame_rate(fr, &c, &n, &d, 0); \ if (av_cmp_q(fr, av_mul_q(ff_mpeg12_frame_rate_tab[c], \ (AVRational) { n + 1, d + 1 })) != 0) { \ av_log(NULL, AV_LOG_ERROR, "Failed to find exact %d/%d: " \ "code = %d, ext_n = %d, ext_d = %d.\n", \ fr.num, fr.den, c, n, d); \ return 1; \ } \ } while (0) // Framerates in the table must be chosen exactly. for (i = 1; i <= 8; i++) TEST_MATCH(ff_mpeg12_frame_rate_tab[i], i, 0, 0); // As should the same ones with small perturbations. // (1/1000 used here to be smaller than half the difference // between 24 and 24000/1001.) for (i = 1; i <= 8; i++) { TEST_MATCH(av_sub_q(ff_mpeg12_frame_rate_tab[i], (AVRational) { 1, 1000 }), i, 0, 0); TEST_MATCH(av_add_q(ff_mpeg12_frame_rate_tab[i], (AVRational) { 1, 1000 }), i, 0, 0); } // Exactly constructable framerates should be exact. Note that some // values can be made in multiple ways (e.g. 12 = 24 / 2 == 60 / 5), // and there is no reason to favour any particular choice. TEST_EXACT( 1, 1); TEST_EXACT( 2, 1); TEST_EXACT( 12, 1); TEST_EXACT( 15000, 1001); TEST_EXACT( 15, 1); TEST_EXACT( 120, 1); TEST_EXACT(120000, 1001); TEST_EXACT( 200, 1); TEST_EXACT( 240, 1); // Values higher than 240 (the highest representable, as 60 * 4 / 1) // should be mapped to 240. for (i = 240; i < 1000; i += 10) TEST_MATCH(((AVRational) { i, 1 }), 8, 3, 0); // Values lower than 24000/32032 (the lowest representable, as // 24000/1001 * 1 / 32) should be mapped to 24000/32032. for (i = 74; i > 0; i--) TEST_MATCH(((AVRational) { i, 100 }), 1, 0, 31); return 0; }
void StringTestCase::Match() { #define TEST_MATCH( s1 , s2 , result ) \ CPPUNIT_ASSERT( wxString(s1).Matches(s2) == result ) TEST_MATCH( wxT("foobar"), wxT("foo*"), true ); TEST_MATCH( wxT("foobar"), wxT("*oo*"), true ); TEST_MATCH( wxT("foobar"), wxT("*bar"), true ); TEST_MATCH( wxT("foobar"), wxT("??????"), true ); TEST_MATCH( wxT("foobar"), wxT("f??b*"), true ); TEST_MATCH( wxT("foobar"), wxT("f?b*"), false ); TEST_MATCH( wxT("foobar"), wxT("*goo*"), false ); TEST_MATCH( wxT("foobar"), wxT("*foo"), false ); TEST_MATCH( wxT("foobarfoo"), wxT("*foo"), true ); TEST_MATCH( wxT(""), wxT("*"), true ); TEST_MATCH( wxT(""), wxT("?"), false ); #undef TEST_MATCH }
int main (int argc, char** argv) { gint total = 0; gint passed = 0; gint failed = 0; gint i; for (i = 1; i < argc; i++) if (strcmp ("--noisy", argv[i]) == 0) noisy = TRUE; TEST_COMPILATION("*A?B*", G_MATCH_ALL, "*A?B*", 3); TEST_COMPILATION("ABC*DEFGH", G_MATCH_ALL_TAIL, "HGFED*CBA", 8); TEST_COMPILATION("ABCDEF*GH", G_MATCH_ALL, "ABCDEF*GH", 8); TEST_COMPILATION("ABC**?***??**DEF*GH", G_MATCH_ALL, "ABC*???DEF*GH", 11); TEST_COMPILATION("*A?AA", G_MATCH_ALL_TAIL, "AA?A*", 4); TEST_COMPILATION("ABCD*", G_MATCH_HEAD, "ABCD", 4); TEST_COMPILATION("*ABCD", G_MATCH_TAIL, "ABCD", 4); TEST_COMPILATION("ABCDE", G_MATCH_EXACT, "ABCDE", 5); TEST_COMPILATION("A?C?E", G_MATCH_ALL, "A?C?E", 5); TEST_COMPILATION("*?x", G_MATCH_ALL_TAIL, "x?*", 2); TEST_COMPILATION("?*x", G_MATCH_ALL_TAIL, "x?*", 2); TEST_COMPILATION("*?*x", G_MATCH_ALL_TAIL, "x?*", 2); TEST_COMPILATION("x*??", G_MATCH_ALL_TAIL, "??*x", 3); TEST_EQUAL("*A?B*", "*A?B*", TRUE); TEST_EQUAL("A*BCD", "A*BCD", TRUE); TEST_EQUAL("ABCD*", "ABCD****", TRUE); TEST_EQUAL("A1*", "A1*", TRUE); TEST_EQUAL("*YZ", "*YZ", TRUE); TEST_EQUAL("A1x", "A1x", TRUE); TEST_EQUAL("AB*CD", "AB**CD", TRUE); TEST_EQUAL("AB*?*CD", "AB*?CD", TRUE); TEST_EQUAL("AB*?CD", "AB?*CD", TRUE); TEST_EQUAL("AB*CD", "AB*?*CD", FALSE); TEST_EQUAL("ABC*", "ABC?", FALSE); TEST_MATCH("*x", "x", TRUE); TEST_MATCH("*x", "xx", TRUE); TEST_MATCH("*x", "yyyx", TRUE); TEST_MATCH("*x", "yyxy", FALSE); TEST_MATCH("?x", "x", FALSE); TEST_MATCH("?x", "xx", TRUE); TEST_MATCH("?x", "yyyx", FALSE); TEST_MATCH("?x", "yyxy", FALSE); TEST_MATCH("*?x", "xx", TRUE); TEST_MATCH("?*x", "xx", TRUE); TEST_MATCH("*?x", "x", FALSE); TEST_MATCH("?*x", "x", FALSE); TEST_MATCH("*?*x", "yx", TRUE); TEST_MATCH("*?*x", "xxxx", TRUE); TEST_MATCH("x*??", "xyzw", TRUE); TEST_MATCH("*x", "\xc3\x84x", TRUE); TEST_MATCH("?x", "\xc3\x84x", TRUE); TEST_MATCH("??x", "\xc3\x84x", FALSE); TEST_MATCH("ab\xc3\xa4\xc3\xb6", "ab\xc3\xa4\xc3\xb6", TRUE); TEST_MATCH("ab\xc3\xa4\xc3\xb6", "abao", FALSE); TEST_MATCH("ab?\xc3\xb6", "ab\xc3\xa4\xc3\xb6", TRUE); TEST_MATCH("ab?\xc3\xb6", "abao", FALSE); TEST_MATCH("ab\xc3\xa4?", "ab\xc3\xa4\xc3\xb6", TRUE); TEST_MATCH("ab\xc3\xa4?", "abao", FALSE); TEST_MATCH("ab??", "ab\xc3\xa4\xc3\xb6", TRUE); TEST_MATCH("ab*", "ab\xc3\xa4\xc3\xb6", TRUE); TEST_MATCH("ab*\xc3\xb6", "ab\xc3\xa4\xc3\xb6", TRUE); TEST_MATCH("ab*\xc3\xb6", "aba\xc3\xb6x\xc3\xb6", TRUE); TEST_MATCH("", "abc", FALSE); TEST_MATCH("", "", TRUE); TEST_MATCH("abc", "abc", TRUE); TEST_MATCH("*fo1*bar", "yyyfoxfo1bar", TRUE); TEST_MATCH("12*fo1g*bar", "12yyyfoxfo1gbar", TRUE); TEST_MATCH("__________:*fo1g*bar", "__________:yyyfoxfo1gbar", TRUE); TEST_MATCH("*abc*cde", "abcde", FALSE); TEST_MATCH("*abc*cde", "abccde", TRUE); TEST_MATCH("*abc*cde", "abcxcde", TRUE); TEST_MATCH("*abc*?cde", "abccde", FALSE); TEST_MATCH("*abc*?cde", "abcxcde", TRUE); TEST_MATCH("*abc*def", "abababcdededef", TRUE); TEST_MATCH("*abc*def", "abcbcbcdededef", TRUE); TEST_MATCH("*acbc*def", "acbcbcbcdededef", TRUE); TEST_MATCH("*a?bc*def", "acbcbcbcdededef", TRUE); TEST_MATCH("*abc*def", "bcbcbcdefdef", FALSE); TEST_MATCH("*abc*def*ghi", "abcbcbcbcbcbcdefefdefdefghi", TRUE); TEST_MATCH("*abc*def*ghi", "bcbcbcbcbcbcdefdefdefdefghi", FALSE); TEST_MATCH("_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_*abc*def*ghi", "_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_abcbcbcbcbcbcdefefdefdefghi", TRUE); TEST_MATCH("fooooooo*a*bc", "fooooooo_a_bd_a_bc", TRUE); verbose ("\n%u tests passed, %u failed\n", passed, failed); return failed; }
int main (int argc, gchar **argv) { gint total = 0; gint passed = 0; gint failed = 0; gint i; for (i = 1; i < argc; i++) if (strcmp ("--noisy", argv[i]) == 0) noisy = TRUE; TEST_MATCH("*x", "x", TRUE); TEST_MATCH("*x", "xx", TRUE); TEST_MATCH("*x", "yyyx", TRUE); TEST_MATCH("*x", "yyxy", FALSE); TEST_MATCH("?x", "x", FALSE); TEST_MATCH("?x", "xx", TRUE); TEST_MATCH("?x", "yyyx", FALSE); TEST_MATCH("?x", "yyxy", FALSE); TEST_MATCH("*?x", "xx", TRUE); TEST_MATCH("?*x", "xx", TRUE); TEST_MATCH("*?x", "x", FALSE); TEST_MATCH("?*x", "x", FALSE); TEST_MATCH("*?*x", "yx", TRUE); TEST_MATCH("*?*x", "xxxx", TRUE); TEST_MATCH("x*??", "xyzw", TRUE); TEST_MATCH("*x", "\xc3\x84x", TRUE); TEST_MATCH("?x", "\xc3\x84x", TRUE); TEST_MATCH("??x", "\xc3\x84x", FALSE); TEST_MATCH("ab\xc3\xa4\xc3\xb6", "ab\xc3\xa4\xc3\xb6", TRUE); TEST_MATCH("ab\xc3\xa4\xc3\xb6", "abao", FALSE); TEST_MATCH("ab?\xc3\xb6", "ab\xc3\xa4\xc3\xb6", TRUE); TEST_MATCH("ab?\xc3\xb6", "abao", FALSE); TEST_MATCH("ab\xc3\xa4?", "ab\xc3\xa4\xc3\xb6", TRUE); TEST_MATCH("ab\xc3\xa4?", "abao", FALSE); TEST_MATCH("ab??", "ab\xc3\xa4\xc3\xb6", TRUE); TEST_MATCH("ab*", "ab\xc3\xa4\xc3\xb6", TRUE); TEST_MATCH("ab*\xc3\xb6", "ab\xc3\xa4\xc3\xb6", TRUE); TEST_MATCH("ab*\xc3\xb6", "aba\xc3\xb6x\xc3\xb6", TRUE); TEST_MATCH("*.o", "gtkcellrendererthreestates.o", TRUE); TEST_MATCH("A*.o", "AA.o", TRUE); TEST_MATCH("A*.o", "aaaa.o", TRUE); TEST_MATCH("A*.o", "B.o", FALSE); verbose ("\n%u tests passed, %u failed\n", passed, failed); return failed; }
int main (int argc, char** argv) { gint total = 0; gint passed = 0; gint failed = 0; gint i; #ifdef __SYMBIAN32__ g_log_set_handler (NULL, G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, &mrtLogHandler, NULL); g_set_print_handler(mrtPrintHandler); #endif /*__SYMBIAN32__*/ for (i = 1; i < argc; i++) if (strcmp ("--noisy", argv[i]) == 0) noisy = TRUE; TEST_COMPILATION("*A?B*", G_MATCH_ALL, "*A?B*", 3); TEST_COMPILATION("ABC*DEFGH", G_MATCH_ALL_TAIL, "HGFED*CBA", 8); TEST_COMPILATION("ABCDEF*GH", G_MATCH_ALL, "ABCDEF*GH", 8); TEST_COMPILATION("ABC**?***??**DEF*GH", G_MATCH_ALL, "ABC*???DEF*GH", 11); TEST_COMPILATION("*A?AA", G_MATCH_ALL_TAIL, "AA?A*", 4); TEST_COMPILATION("ABCD*", G_MATCH_HEAD, "ABCD", 4); TEST_COMPILATION("*ABCD", G_MATCH_TAIL, "ABCD", 4); TEST_COMPILATION("ABCDE", G_MATCH_EXACT, "ABCDE", 5); TEST_COMPILATION("A?C?E", G_MATCH_ALL, "A?C?E", 5); TEST_COMPILATION("*?x", G_MATCH_ALL_TAIL, "x?*", 2); TEST_COMPILATION("?*x", G_MATCH_ALL_TAIL, "x?*", 2); TEST_COMPILATION("*?*x", G_MATCH_ALL_TAIL, "x?*", 2); TEST_COMPILATION("x*??", G_MATCH_ALL_TAIL, "??*x", 3); TEST_EQUAL("*A?B*", "*A?B*", TRUE); TEST_EQUAL("A*BCD", "A*BCD", TRUE); TEST_EQUAL("ABCD*", "ABCD****", TRUE); TEST_EQUAL("A1*", "A1*", TRUE); TEST_EQUAL("*YZ", "*YZ", TRUE); TEST_EQUAL("A1x", "A1x", TRUE); TEST_EQUAL("AB*CD", "AB**CD", TRUE); TEST_EQUAL("AB*?*CD", "AB*?CD", TRUE); TEST_EQUAL("AB*?CD", "AB?*CD", TRUE); TEST_EQUAL("AB*CD", "AB*?*CD", FALSE); TEST_EQUAL("ABC*", "ABC?", FALSE); TEST_MATCH("*x", "x", TRUE); TEST_MATCH("*x", "xx", TRUE); TEST_MATCH("*x", "yyyx", TRUE); TEST_MATCH("*x", "yyxy", FALSE); TEST_MATCH("?x", "x", FALSE); TEST_MATCH("?x", "xx", TRUE); TEST_MATCH("?x", "yyyx", FALSE); TEST_MATCH("?x", "yyxy", FALSE); TEST_MATCH("*?x", "xx", TRUE); TEST_MATCH("?*x", "xx", TRUE); TEST_MATCH("*?x", "x", FALSE); TEST_MATCH("?*x", "x", FALSE); TEST_MATCH("*?*x", "yx", TRUE); TEST_MATCH("*?*x", "xxxx", TRUE); TEST_MATCH("x*??", "xyzw", TRUE); TEST_MATCH("*x", "\xc3\x84x", TRUE); TEST_MATCH("?x", "\xc3\x84x", TRUE); TEST_MATCH("??x", "\xc3\x84x", FALSE); TEST_MATCH("ab\xc3\xa4\xc3\xb6", "ab\xc3\xa4\xc3\xb6", TRUE); TEST_MATCH("ab\xc3\xa4\xc3\xb6", "abao", FALSE); TEST_MATCH("ab?\xc3\xb6", "ab\xc3\xa4\xc3\xb6", TRUE); TEST_MATCH("ab?\xc3\xb6", "abao", FALSE); TEST_MATCH("ab\xc3\xa4?", "ab\xc3\xa4\xc3\xb6", TRUE); TEST_MATCH("ab\xc3\xa4?", "abao", FALSE); TEST_MATCH("ab??", "ab\xc3\xa4\xc3\xb6", TRUE); TEST_MATCH("ab*", "ab\xc3\xa4\xc3\xb6", TRUE); TEST_MATCH("ab*\xc3\xb6", "ab\xc3\xa4\xc3\xb6", TRUE); TEST_MATCH("ab*\xc3\xb6", "aba\xc3\xb6x\xc3\xb6", TRUE); TEST_MATCH("", "abc", FALSE); TEST_MATCH("", "", TRUE); TEST_MATCH("abc", "abc", TRUE); TEST_MATCH("*fo1*bar", "yyyfoxfo1bar", TRUE); TEST_MATCH("12*fo1g*bar", "12yyyfoxfo1gbar", TRUE); TEST_MATCH("__________:*fo1g*bar", "__________:yyyfoxfo1gbar", TRUE); TEST_MATCH("*abc*cde", "abcde", FALSE); TEST_MATCH("*abc*cde", "abccde", TRUE); TEST_MATCH("*abc*cde", "abcxcde", TRUE); TEST_MATCH("*abc*?cde", "abccde", FALSE); TEST_MATCH("*abc*?cde", "abcxcde", TRUE); TEST_MATCH("*abc*def", "abababcdededef", TRUE); TEST_MATCH("*abc*def", "abcbcbcdededef", TRUE); TEST_MATCH("*acbc*def", "acbcbcbcdededef", TRUE); TEST_MATCH("*a?bc*def", "acbcbcbcdededef", TRUE); TEST_MATCH("*abc*def", "bcbcbcdefdef", FALSE); TEST_MATCH("*abc*def*ghi", "abcbcbcbcbcbcdefefdefdefghi", TRUE); TEST_MATCH("*abc*def*ghi", "bcbcbcbcbcbcdefdefdefdefghi", FALSE); TEST_MATCH("_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_*abc*def*ghi", "_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_abcbcbcbcbcbcdefefdefdefghi", TRUE); TEST_MATCH("fooooooo*a*bc", "fooooooo_a_bd_a_bc", TRUE); verbose ("\n%u tests passed, %u failed\n", passed, failed); #ifdef __SYMBIAN32__ testResultXml("patterntest"); #endif /* EMULATOR */ return failed; }