Home | History | Annotate | Download | only in tests

Lines Matching refs:pattern

95 test_new (const gchar        *pattern,
101 verbose ("compiling \"%s\" \t", pattern);
103 regex = g_regex_new (pattern, compile_opts, match_opts, NULL);
106 g_print ("failed \t(pattern: \"%s\", compile: %d, match %d)\n",
107 pattern, compile_opts, match_opts);
111 if (!streq (g_regex_get_pattern (regex), pattern))
113 g_print ("failed \t(pattern: \"%s\")\n",
114 pattern);
125 #define TEST_NEW(pattern, compile_opts, match_opts) { \
127 if (test_new (pattern, compile_opts, match_opts)) \
134 test_new_fail (const gchar *pattern,
141 verbose ("compiling \"%s\" (expected a failure) \t", pattern);
143 regex = g_regex_new (pattern, compile_opts, 0, &error);
147 g_print ("failed \t(pattern: \"%s\", compile: %d)\n",
148 pattern, compile_opts);
155 g_print ("failed \t(pattern: \"%s\", compile: %d, got error: %d, "
157 pattern, compile_opts, error->code, expected_error);
166 #define TEST_NEW_FAIL(pattern, compile_opts, expected_error) { \
168 if (test_new_fail (pattern, compile_opts, expected_error)) \
175 test_match_simple (const gchar *pattern,
183 verbose ("matching \"%s\" against \"%s\" \t", string, pattern);
185 match = g_regex_match_simple (pattern, string, compile_opts, match_opts);
198 #define TEST_MATCH_SIMPLE(pattern, string, compile_opts, match_opts, expected) { \
200 if (test_match_simple (pattern, string, compile_opts, match_opts, expected)) \
207 test_match (const gchar *pattern,
220 string, pattern, start_position, string_len);
222 regex = g_regex_new (pattern, compile_opts, match_opts, NULL);
227 gchar *e1 = g_strescape (pattern, NULL);
241 g_print ("failed \t(pattern: \"%s\", string: \"%s\")\n",
242 pattern, string);
254 #define TEST_MATCH(pattern, compile_opts, match_opts, string, \
257 if (test_match (pattern, compile_opts, match_opts, string, \
282 test_match_next (const gchar *pattern,
297 string, pattern, start_position, string_len);
317 regex = g_regex_new (pattern, 0, 0, NULL);
389 #define TEST_MATCH_NEXT0(pattern, string, string_len, start_position) { \
391 if (test_match_next (pattern, string, string_len, start_position, NULL)) \
397 #define TEST_MATCH_NEXT1(pattern, string, string_len, start_position, \
400 if (test_match_next (pattern, string, string_len, start_position, \
407 #define TEST_MATCH_NEXT2(pattern, string, string_len, start_position, \
410 if (test_match_next (pattern, string, string_len, start_position, \
417 #define TEST_MATCH_NEXT3(pattern, string, string_len, start_position, \
420 if (test_match_next (pattern, string, string_len, start_position, \
427 #define TEST_MATCH_NEXT4(pattern, string, string_len, start_position, \
430 if (test_match_next (pattern, string, string_len, start_position, \
438 test_match_count (const gchar *pattern,
448 verbose ("fetching match count (string: \"%s\", pattern: \"%s\", start: %d) \t",
449 string, pattern, start_position);
451 regex = g_regex_new (pattern, 0, 0, NULL);
470 #define TEST_MATCH_COUNT(pattern, string, start_position, match_opts, expected_count) { \
472 if (test_match_count (pattern, string, start_position, match_opts, expected_count)) \
479 test_partial (const gchar *pattern,
486 verbose ("partial matching (string: \"%s\", pattern: \"%s\") \t",
487 string, pattern);
489 regex = g_regex_new (pattern, 0, 0, NULL);
501 g_print ("failed \t(got sub-pattern 0)\n");
508 g_print ("failed \t(got sub-pattern 1)\n");
520 #define TEST_PARTIAL(pattern, string, expected) { \
522 if (test_partial (pattern, string, expected)) \
529 test_sub_pattern (const gchar *pattern,
542 verbose ("fetching sub-pattern %d from \"%s\" (pattern: \"%s\") \t",
543 sub_n, string, pattern);
545 regex = g_regex_new (pattern, 0, 0, NULL);
575 #define TEST_SUB_PATTERN(pattern, string, start_position, sub_n, expected_sub, \
578 if (test_sub_pattern (pattern, string, start_position, sub_n, expected_sub, \
586 test_named_sub_pattern (const gchar *pattern,
600 verbose ("fetching sub-pattern \"%s\" from \"%s\" (pattern: \"%s\") \t",
601 sub_name, string, pattern);
603 regex = g_regex_new (pattern, flags, 0, NULL);
633 #define TEST_NAMED_SUB_PATTERN(pattern, string, start_position, sub_name, \
636 if (test_named_sub_pattern (pattern, 0, string, start_position, sub_name, \
643 #define TEST_NAMED_SUB_PATTERN_DUPNAMES(pattern, string, start_position, sub_name, \
646 if (test_named_sub_pattern (pattern, G_REGEX_DUPNAMES, string, start_position, \
654 test_fetch_all (const gchar *pattern,
668 verbose ("fetching all sub-patterns from \"%s\" (pattern: \"%s\") \t",
669 string, pattern);
684 regex = g_regex_new (pattern, 0, 0, NULL);
726 #define TEST_FETCH_ALL0(pattern, string) { \
728 if (test_fetch_all (pattern, string, NULL)) \
734 #define TEST_FETCH_ALL1(pattern, string, e1) { \
736 if (test_fetch_all (pattern, string, e1, NULL)) \
742 #define TEST_FETCH_ALL2(pattern, string, e1, e2) { \
744 if (test_fetch_all (pattern, string, e1, e2, NULL)) \
750 #define TEST_FETCH_ALL3(pattern, string, e1, e2, e3) { \
752 if (test_fetch_all (pattern, string, e1, e2, e3, NULL)) \
759 test_split_simple (const gchar *pattern,
771 verbose ("splitting \"%s\" against \"%s\" \t", string, pattern);
786 tokens = g_regex_split_simple (pattern, string, 0, 0);
824 #define TEST_SPLIT_SIMPLE0(pattern, string) { \
826 if (test_split_simple (pattern, string, NULL)) \
832 #define TEST_SPLIT_SIMPLE1(pattern, string, e1) { \
834 if (test_split_simple (pattern, string, e1, NULL)) \
840 #define TEST_SPLIT_SIMPLE2(pattern, string, e1, e2) { \
842 if (test_split_simple (pattern, string, e1, e2, NULL)) \
848 #define TEST_SPLIT_SIMPLE3(pattern, string, e1, e2, e3) { \
850 if (test_split_simple (pattern, string, e1, e2, e3, NULL)) \
857 test_split_full (const gchar *pattern,
873 string, pattern, start_position, max_tokens);
888 regex = g_regex_new (pattern, 0, 0, NULL);
930 test_split (const gchar *pattern,
943 verbose ("splitting \"%s\" against \"%s\" \t", string, pattern);
958 regex = g_regex_new (pattern, 0, 0, NULL);
998 #define TEST_SPLIT0(pattern, string, start_position, max_tokens) { \
1000 if (test_split_full (pattern, string, start_position, max_tokens, NULL)) \
1007 if (test_split (pattern, string, NULL)) \
1014 #define TEST_SPLIT1(pattern, string, start_position, max_tokens, e1) { \
1016 if (test_split_full (pattern, string, start_position, max_tokens, e1, NULL)) \
1023 if (test_split (pattern, string, e1, NULL)) \
1030 #define TEST_SPLIT2(pattern, string, start_position, max_tokens, e1, e2) { \
1032 if (test_split_full (pattern, string, start_position, max_tokens, e1, e2, NULL)) \
1039 if (test_split (pattern, string, e1, e2, NULL)) \
1046 #define TEST_SPLIT3(pattern, string, start_position, max_tokens, e1, e2, e3) { \
1048 if (test_split_full (pattern, string, start_position, max_tokens, e1, e2, e3, NULL)) \
1055 if (test_split (pattern, string, e1, e2, e3, NULL)) \
1101 test_expand (const gchar *pattern,
1111 verbose ("expanding the references in \"%s\" (pattern: \"%s\", string: \"%s\") \t",
1113 pattern ? pattern : "(null)",
1116 if (pattern)
1118 regex = g_regex_new (pattern, raw ? G_REGEX_RAW : 0, 0, NULL);
1141 #define TEST_EXPAND(pattern, string, string_to_expand, raw, expected) { \
1143 if (test_expand (pattern, string, string_to_expand, raw, expected)) \
1150 test_replace (const gchar *pattern,
1159 verbose ("replacing \"%s\" in \"%s\" (pattern: \"%s\", start: %d) \t",
1160 replacement, string, pattern, start_position);
1162 regex = g_regex_new (pattern, 0, 0, NULL);
1179 #define TEST_REPLACE(pattern, string, start_position, replacement, expected) { \
1181 if (test_replace (pattern, string, start_position, replacement, expected)) \
1188 test_replace_lit (const gchar *pattern,
1197 verbose ("replacing literally \"%s\" in \"%s\" (pattern: \"%s\", start: %d) \t",
1198 replacement, string, pattern, start_position);
1200 regex = g_regex_new (pattern, 0, 0, NULL);
1218 #define TEST_REPLACE_LIT(pattern, string, start_position, replacement, expected) { \
1220 if (test_replace_lit (pattern, string, start_position, replacement, expected)) \
1227 test_get_string_number (const gchar *pattern,
1234 verbose ("getting the number of \"%s\" (pattern: \"%s\") \t",
1235 name, pattern);
1237 regex = g_regex_new (pattern, 0, 0, NULL);
1253 #define TEST_GET_STRING_NUMBER(pattern, name, expected_num) { \
1255 if (test_get_string_number (pattern, name, expected_num)) \
1294 test_match_all_full (const gchar *pattern,
1311 string, pattern, start_position, string_len);
1331 regex = g_regex_new (pattern, 0, 0, NULL);
1404 test_match_all (const gchar *pattern,
1418 verbose ("matching all in \"%s\" against \"%s\" \t", string, pattern);
1438 regex = g_regex_new (pattern, 0, 0, NULL);
1509 #define TEST_MATCH_ALL0(pattern, string, string_len, start_position) { \
1511 if (test_match_all_full (pattern, string, string_len, start_position, NULL)) \
1518 if (test_match_all (pattern, string, NULL)) \
1525 #define TEST_MATCH_ALL1(pattern, string, string_len, start_position, \
1528 if (test_match_all_full (pattern, string, string_len, start_position, \
1536 if (test_match_all (pattern, string, t1, s1, e1, NULL)) \
1543 #define TEST_MATCH_ALL2(pattern, string, string_len, start_position, \
1546 if (test_match_all_full (pattern, string, string_len, start_position, \
1554 if (test_match_all (pattern, string, t1, s1, e1, t2, s2, e2, NULL)) \
1561 #define TEST_MATCH_ALL3(pattern, string, string_len, start_position, \
1564 if (test_match_all_full (pattern, string, string_len, start_position, \
1572 if (test_match_all (pattern, string, t1, s1, e1, t2, s2, e2, t3, s3, e3, NULL)) \
1599 /* TEST_NEW(pattern, compile_opts, match_opts) */
1614 /* TEST_NEW_FAIL(pattern, compile_opts, expected_error) */
1622 /* TEST_MATCH_SIMPLE(pattern, string, compile_opts, match_opts, expected) */
1695 /* TEST_MATCH(pattern, compile_opts, match_opts, string,
1768 /* TEST_MATCH_NEXT#(pattern, string, string_len, start_position, ...) */
1792 /* TEST_MATCH_COUNT(pattern, string, start_position, match_opts, expected_count) */
1804 /* TEST_PARTIAL(pattern, string, expected) */
1813 /* TEST_SUB_PATTERN(pattern, string, start_position, sub_n, expected_sub,
1826 /* TEST_NAMED_SUB_PATTERN(pattern, string, start_position, sub_name,
1838 /* TEST_NAMED_SUB_PATTERN_DUPNAMES(pattern, string, start_position, sub_name,
1846 /* DUPNAMES option inside the pattern */
1853 /* TEST_FETCH_ALL#(pattern, string, ...) */
1868 /* TEST_SPLIT_SIMPLE#(pattern, string, ...) */
1889 /* TEST_SPLIT#(pattern, string, start_position, max_tokens, ...) */
1931 /* TEST_EXPAND(pattern, string, string_to_expand, raw, expected) */
1997 /* Pattern-less. */
2004 /* TEST_REPLACE(pattern, string, start_position, replacement, expected) */
2032 /* TEST_REPLACE_LIT(pattern, string, start_position, replacement, expected) */
2054 /* TEST_GET_STRING_NUMBER(pattern, name, expected_num) */
2088 /* TEST_MATCH_ALL#(pattern, string, string_len, start_position, ...) */