2 #include "ace/Log_Msg.h"
3 #include "test_config.h"
5 bool match (const char *str
, const char *pat
, bool cs
= true, bool cc
= false)
7 bool const result
= ACE::wild_match (str
, pat
, cs
, cc
);
8 ACE_DEBUG ((LM_DEBUG
, "string {%C} %C pattern {%C}\t%C\t%C\n", str
,
9 (result
? "matches" : "does not match"), pat
,
10 (cs
? "" : "case-insensitive"), (cc
? "char classes" : "")));
14 int run_main (int, ACE_TCHAR
*[])
16 ACE_START_TEST (ACE_TEXT ("Wild_Match_Test"));
19 ok
&= match ("foo_baz_bar", "foo*bar");
20 ok
&= match ("lksfj;laskf;jbaz", "*baz");
21 ok
&= !match ("abc", "abc?");
22 ok
&= match ("simple", "simple");
23 ok
&= !match ("not so simple", "simple");
24 ok
&= match ("AbC", "abc", false);
25 ok
&= match ("*\\", "\\*\\\\");
26 ok
&= match ("Nonwild[foo]", "*[foo]");
27 ok
&= match ("Apple][", "[zxya]p*[]125]\\[", false, true);
28 ok
&= match ("[!]", "[][!][][!][][!]", true, true);
29 ok
&= match ("ace", "[a-e][a-e][a-e]", true, true);
30 ok
&= match ("--x", "[-1][2-][!-]", true, true);
32 ok
&= !match ("C2", "[!C]?", true, true);
33 ok
&= match ("D1", "[!C]?", true, true);
34 ok
&= match ("D2", "[!C]?", true, true);
36 ok
&= !match ("C2", "?[!2]", true, true);
37 ok
&= match ("C1", "?[!2]", true, true);
38 ok
&= !match (0, "[!C]?", true, true);
40 // invalid classes: results are undefined but we shouldn't crash
41 match ("foo", "f[o-a]o", true, true);
42 match ("bar", "[f-", true, true);
43 match ("bar", "[z", true, true);
44 match ("bar", "[]x", true, true);
45 match ("foo", "[f-f]oo", true, true);
49 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("ERROR: Wild_Match_Test failed\n")));