mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 15:03:39 +02:00
Remain silent when sucessful.
2003-05-28 Matthias Clasen <maclas@gmx.de> * tests/patterntest.c: Remain silent when sucessful. * tests/Makefile.am: Add patterntest to make check. (#113143, Zach Frey)
This commit is contained in:
committed by
Matthias Clasen
parent
c868c58694
commit
25e8ae683e
@@ -19,6 +19,7 @@
|
||||
|
||||
#undef G_DISABLE_ASSERT
|
||||
#undef G_LOG_DOMAIN
|
||||
#undef NOISY
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -86,7 +87,9 @@ test_compilation (gchar *src,
|
||||
{
|
||||
GPatternSpec *spec;
|
||||
|
||||
#ifdef NOISY
|
||||
g_print ("compiling \"%s\" \t", utf8(src));
|
||||
#endif
|
||||
spec = g_pattern_spec_new (src);
|
||||
|
||||
if (spec->match_type != match_type)
|
||||
@@ -121,9 +124,11 @@ test_compilation (gchar *src,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef NOISY
|
||||
g_print ("passed (%s: \"%s\")\n",
|
||||
match_type_name (spec->match_type),
|
||||
spec->pattern);
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -133,7 +138,9 @@ test_match (gchar *pattern,
|
||||
gchar *string,
|
||||
gboolean match)
|
||||
{
|
||||
#ifdef NOISY
|
||||
g_print ("matching \"%s\" against \"%s\" \t", utf8(string), utf8(pattern));
|
||||
#endif
|
||||
|
||||
if (g_pattern_match_simple (pattern, string) != match)
|
||||
{
|
||||
@@ -141,7 +148,9 @@ test_match (gchar *pattern,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef NOISY
|
||||
g_print ("passed (%s)\n", match ? "match" : "nomatch");
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -154,7 +163,9 @@ test_equal (gchar *pattern1,
|
||||
GPatternSpec *p2 = g_pattern_spec_new (pattern2);
|
||||
gboolean equal = g_pattern_spec_equal (p1, p2);
|
||||
|
||||
#ifdef NOISY
|
||||
g_print ("comparing \"%s\" with \"%s\" \t", utf8(pattern1), utf8(pattern2));
|
||||
#endif
|
||||
|
||||
if (expected != equal)
|
||||
{
|
||||
@@ -163,8 +174,10 @@ test_equal (gchar *pattern1,
|
||||
expected ? "!=" : "==",
|
||||
match_type_name (p2->match_type), p2->pattern_length, utf8(p2->pattern));
|
||||
}
|
||||
#ifdef NOISY
|
||||
else
|
||||
g_print ("passed (%s)\n", equal ? "equal" : "unequal");
|
||||
#endif
|
||||
|
||||
g_pattern_spec_free (p1);
|
||||
g_pattern_spec_free (p2);
|
||||
@@ -217,17 +230,17 @@ main (int argc, char** argv)
|
||||
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_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);
|
||||
@@ -258,7 +271,11 @@ main (int argc, char** argv)
|
||||
TEST_MATCH("ab*\xf6", "ab\xe4\xf6", TRUE);
|
||||
TEST_MATCH("ab*\xf6", "aba\xf6x\xf6", TRUE);
|
||||
|
||||
#ifdef NOISY
|
||||
g_print ("\n%u tests passed, %u failed\n", passed, failed);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
return failed;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user