Esempio n. 1
0
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;
}
Esempio n. 2
0
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;
}