Add failing tests for {idx:\d{3}}-{idy:\d{3}} pattern
This commit is contained in:
parent
b3e6321303
commit
268047c18c
2 changed files with 58 additions and 61 deletions
|
@ -358,3 +358,29 @@
|
||||||
1400573847,10478482.69
|
1400573847,10478482.69
|
||||||
1400573855,15087645.17
|
1400573855,15087645.17
|
||||||
1400573891,15207920.79
|
1400573891,15207920.79
|
||||||
|
1400592138,13289883.29
|
||||||
|
1400592160,13689866.38
|
||||||
|
1400592167,13887614.50
|
||||||
|
1400592181,12902438.30
|
||||||
|
1400592212,12711239.59
|
||||||
|
1400592282,13868279.63
|
||||||
|
1400592287,14008688.28
|
||||||
|
1400592314,13915819.27
|
||||||
|
1400592447,13857005.45
|
||||||
|
1400592453,13737673.35
|
||||||
|
1400592520,13746939.61
|
||||||
|
1400592698,13522088.67
|
||||||
|
1400592756,14069856.66
|
||||||
|
1400592898,13964804.85
|
||||||
|
1400592906,12335090.17
|
||||||
|
1400592931,14145688.00
|
||||||
|
1400592964,13071020.50
|
||||||
|
1400593034,13921007.60
|
||||||
|
1400593050,12790569.45
|
||||||
|
1400593062,13672159.26
|
||||||
|
1400593069,13522175.86
|
||||||
|
1400593171,13911803.66
|
||||||
|
1400593186,13788854.92
|
||||||
|
1400593197,13978543.79
|
||||||
|
1400593210,13568445.16
|
||||||
|
1400593219,13704926.07
|
||||||
|
|
|
|
@ -70,19 +70,6 @@ START_TEST (test_compile)
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
r3_tree_dump(n, 0);
|
r3_tree_dump(n, 0);
|
||||||
#endif
|
#endif
|
||||||
/*
|
|
||||||
fail_if(n->edges[0]->child->combined_pattern == NULL);
|
|
||||||
|
|
||||||
e = r3_node_find_edge_str(n, "/", strlen("/") );
|
|
||||||
fail_if( NULL == e );
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
printf( "%s\n", e->pattern );
|
|
||||||
printf( "%s\n", e->child->combined_pattern );
|
|
||||||
printf( "%s\n", n->edges[0]->child->combined_pattern);
|
|
||||||
printf( "%s\n", n->combined_pattern );
|
|
||||||
*/
|
|
||||||
|
|
||||||
match_entry * entry;
|
match_entry * entry;
|
||||||
|
|
||||||
entry = match_entry_createl( "foo" , strlen("/foo") );
|
entry = match_entry_createl( "foo" , strlen("/foo") );
|
||||||
|
@ -112,60 +99,14 @@ START_TEST (test_compile)
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
START_TEST (test_compile_slug)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
char * pattern;
|
|
||||||
pattern = compile_slug("{id}", strlen("{id}"));
|
|
||||||
ck_assert_str_eq( pattern, "([^/]+)" );
|
|
||||||
free(pattern);
|
|
||||||
|
|
||||||
pattern = compile_slug("/{id}", strlen("/{id}"));
|
|
||||||
ck_assert_str_eq( pattern, "/([^/]+)" );
|
|
||||||
free(pattern);
|
|
||||||
|
|
||||||
pattern = compile_slug("-{id}", strlen("-{id}"));
|
|
||||||
ck_assert_str_eq( pattern, "-([^-]+)" );
|
|
||||||
free(pattern);
|
|
||||||
|
|
||||||
pattern = compile_slug("{id}-{title}", strlen("{id}-{title}"));
|
|
||||||
ck_assert_str_eq( pattern, "([^/]+)-([^-]+)" );
|
|
||||||
free(pattern);
|
|
||||||
|
|
||||||
|
|
||||||
pattern = compile_slug("{id:[a-z]+}", strlen("{id:[a-z]+}") );
|
|
||||||
ck_assert_str_eq( pattern, "([a-z]+)" );
|
|
||||||
free(pattern);
|
|
||||||
|
|
||||||
|
|
||||||
pattern = compile_slug("/path/{id:[a-z]+}", strlen("/path/{id:[a-z]+}") );
|
|
||||||
ck_assert_str_eq( pattern, "/path/([a-z]+)" );
|
|
||||||
free(pattern);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
char * p = malloc(sizeof(char) * 10);
|
|
||||||
strncat(p, "foo", 3);
|
|
||||||
free(p);
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
END_TEST
|
|
||||||
|
|
||||||
|
|
||||||
START_TEST (test_pcre_patterns_insert)
|
START_TEST (test_pcre_patterns_insert)
|
||||||
{
|
{
|
||||||
node * n = r3_tree_create(10);
|
node * n = r3_tree_create(10);
|
||||||
|
|
||||||
// r3_tree_insert_path(n, "/foo-{user}-{id}", NULL, NULL);
|
// r3_tree_insert_path(n, "/foo-{user}-{id}", NULL, NULL);
|
||||||
// r3_tree_dump(n, 0);
|
|
||||||
r3_tree_insert_path(n, "/post/{handle:\\d+}-{id:\\d+}", NULL);
|
r3_tree_insert_path(n, "/post/{handle:\\d+}-{id:\\d+}", NULL);
|
||||||
r3_tree_compile(n);
|
r3_tree_compile(n);
|
||||||
r3_tree_dump(n, 0);
|
// r3_tree_dump(n, 0);
|
||||||
|
|
||||||
node *matched;
|
node *matched;
|
||||||
matched = r3_tree_matchl(n, "/post/111-222", strlen("/post/111-222"), NULL);
|
matched = r3_tree_matchl(n, "/post/111-222", strlen("/post/111-222"), NULL);
|
||||||
|
@ -182,6 +123,36 @@ START_TEST (test_pcre_patterns_insert)
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test for \d{3}-\d{4}
|
||||||
|
*/
|
||||||
|
START_TEST (test_pcre_patterns_insert_2)
|
||||||
|
{
|
||||||
|
node * n = r3_tree_create(10);
|
||||||
|
|
||||||
|
// r3_tree_insert_path(n, "/foo-{user}-{id}", NULL, NULL);
|
||||||
|
// r3_tree_dump(n, 0);
|
||||||
|
r3_tree_insert_path(n, "/post/{idx:\\d{2}}/{idy:\\d{2}}", NULL);
|
||||||
|
r3_tree_compile(n);
|
||||||
|
r3_tree_dump(n, 0);
|
||||||
|
|
||||||
|
node *matched;
|
||||||
|
matched = r3_tree_match(n, "/post/11/22", NULL);
|
||||||
|
ck_assert(matched);
|
||||||
|
ck_assert(matched->endpoint > 0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
matched = r3_tree_match(n, "/post/11", NULL);
|
||||||
|
ck_assert(matched);
|
||||||
|
ck_assert_int_eq(matched->endpoint, 0);
|
||||||
|
r3_tree_free(n);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
START_TEST (test_r3_tree_insert_pathl)
|
START_TEST (test_r3_tree_insert_pathl)
|
||||||
|
@ -743,13 +714,13 @@ Suite* r3_suite (void) {
|
||||||
tcase_add_test(tcase, test_ltrim_slash);
|
tcase_add_test(tcase, test_ltrim_slash);
|
||||||
tcase_add_test(tcase, test_r3_node_find_edge);
|
tcase_add_test(tcase, test_r3_node_find_edge);
|
||||||
tcase_add_test(tcase, test_r3_tree_insert_pathl);
|
tcase_add_test(tcase, test_r3_tree_insert_pathl);
|
||||||
tcase_add_test(tcase, test_compile_slug);
|
|
||||||
tcase_add_test(tcase, test_compile);
|
tcase_add_test(tcase, test_compile);
|
||||||
tcase_add_test(tcase, test_route_cmp);
|
tcase_add_test(tcase, test_route_cmp);
|
||||||
tcase_add_test(tcase, test_insert_route);
|
tcase_add_test(tcase, test_insert_route);
|
||||||
tcase_add_test(tcase, test_pcre_pattern_simple);
|
tcase_add_test(tcase, test_pcre_pattern_simple);
|
||||||
tcase_add_test(tcase, test_pcre_pattern_more);
|
tcase_add_test(tcase, test_pcre_pattern_more);
|
||||||
tcase_add_test(tcase, test_pcre_patterns_insert);
|
tcase_add_test(tcase, test_pcre_patterns_insert);
|
||||||
|
tcase_add_test(tcase, test_pcre_patterns_insert_2);
|
||||||
tcase_add_test(tcase, benchmark_str);
|
tcase_add_test(tcase, benchmark_str);
|
||||||
|
|
||||||
suite_add_tcase(suite, tcase);
|
suite_add_tcase(suite, tcase);
|
||||||
|
|
Loading…
Reference in a new issue