[bcl] Fix a few hardcoded socket ports in tests (#5471)
[mono-project.git] / mono / eglib / test / pattern.c
blob7db5a7be3dea442ebc76e9802e4f1aa29744787c
1 #include <config.h>
2 #include <glib.h>
3 #include <string.h>
4 #include <stdlib.h>
5 #ifdef HAVE_UNISTD_H
6 #include <unistd.h>
7 #endif
8 #include <stdio.h>
9 #include "test.h"
11 #define MATCH(pat,string,error_if,msg) \
12 spec = g_pattern_spec_new (pat); \
13 res = g_pattern_match_string (spec, string); \
14 if (res == error_if) \
15 return FAILED (msg " returned %s", res ? "TRUE" : "FALSE"); \
16 g_pattern_spec_free (spec);
18 #define TEST_MATCH(pat,string,n) MATCH (pat, string, FALSE, "MATCH " #n)
19 #define TEST_NO_MATCH(pat,string,n) MATCH (pat, string,TRUE, "NO_MATCH " #n)
21 RESULT
22 test_pattern_spec ()
24 GPatternSpec *spec;
25 gboolean res;
27 /* spec = g_pattern_spec_new (NULL); */
28 TEST_MATCH ("*", "hola", 1);
29 TEST_MATCH ("hola", "hola", 2);
30 TEST_MATCH ("????", "hola", 3);
31 TEST_MATCH ("???a", "hola", 4);
32 TEST_MATCH ("h??a", "hola", 5);
33 TEST_MATCH ("h??*", "hola", 6);
34 TEST_MATCH ("h*", "hola", 7);
35 TEST_MATCH ("*hola", "hola", 8);
36 TEST_MATCH ("*l*", "hola", 9);
37 TEST_MATCH ("h*??", "hola", 10);
38 TEST_MATCH ("h*???", "hola", 11);
39 TEST_MATCH ("?o??", "hola", 12);
40 TEST_MATCH ("*h*o*l*a*", "hola", 13);
41 TEST_MATCH ("h*o*l*a", "hola", 14);
42 TEST_MATCH ("h?*?", "hola", 15);
44 TEST_NO_MATCH ("", "hola", 1);
45 TEST_NO_MATCH ("?????", "hola", 2);
46 TEST_NO_MATCH ("???", "hola", 3);
47 TEST_NO_MATCH ("*o", "hola", 4);
48 TEST_NO_MATCH ("h", "hola", 5);
49 TEST_NO_MATCH ("h*????", "hola", 6);
51 return OK;
54 static Test pattern_tests [] = {
55 {"g_pattern_spec*", test_pattern_spec},
56 {NULL, NULL}
59 DEFINE_TEST_GROUP_INIT(pattern_tests_init, pattern_tests)