r3_tree_matchl does not return int

This commit is contained in:
c9s 2014-05-21 18:31:51 +08:00
parent b83946e487
commit 05b698b841
2 changed files with 12 additions and 11 deletions

View file

@ -445,3 +445,4 @@
1400666950,6684744.95 1400666950,6684744.95
1400667091,6771202.47 1400667091,6771202.47
1400667800,6695271.95 1400667800,6695271.95
1400668268,13174604.57

1 1400242718 5649455.80
445 1400666950 6684744.95
446 1400667091 6771202.47
447 1400667800 6695271.95
448 1400668268 13174604.57

View file

@ -72,27 +72,27 @@ START_TEST (test_compile)
entry = match_entry_createl( "foo" , strlen("/foo") ); entry = match_entry_createl( "foo" , strlen("/foo") );
m = r3_tree_matchl( n , "/foo", strlen("/foo"), entry); m = r3_tree_matchl( n , "/foo", strlen("/foo"), entry);
ck_assert( (int)m ); ck_assert( m );
entry = match_entry_createl( "/zoo" , strlen("/zoo") ); entry = match_entry_createl( "/zoo" , strlen("/zoo") );
m = r3_tree_matchl( n , "/zoo", strlen("/zoo"), entry); m = r3_tree_matchl( n , "/zoo", strlen("/zoo"), entry);
ck_assert( (int)m ); ck_assert( m );
entry = match_entry_createl( "/bar" , strlen("/bar") ); entry = match_entry_createl( "/bar" , strlen("/bar") );
m = r3_tree_matchl( n , "/bar", strlen("/bar"), entry); m = r3_tree_matchl( n , "/bar", strlen("/bar"), entry);
ck_assert( (int)m ); ck_assert( m );
entry = match_entry_createl( "/xxx" , strlen("/xxx") ); entry = match_entry_createl( "/xxx" , strlen("/xxx") );
m = r3_tree_matchl( n , "/xxx", strlen("/xxx"), entry); m = r3_tree_matchl( n , "/xxx", strlen("/xxx"), entry);
ck_assert( (int)m ); ck_assert( m );
entry = match_entry_createl( "/foo/xxx" , strlen("/foo/xxx") ); entry = match_entry_createl( "/foo/xxx" , strlen("/foo/xxx") );
m = r3_tree_matchl( n , "/foo/xxx", strlen("/foo/xxx"), entry); m = r3_tree_matchl( n , "/foo/xxx", strlen("/foo/xxx"), entry);
ck_assert( (int)m ); ck_assert( m );
entry = match_entry_createl( "/some_id" , strlen("/some_id") ); entry = match_entry_createl( "/some_id" , strlen("/some_id") );
m = r3_tree_matchl( n , "/some_id", strlen("/some_id"), entry); m = r3_tree_matchl( n , "/some_id", strlen("/some_id"), entry);
ck_assert( (int)m ); ck_assert( m );
} }
END_TEST END_TEST
@ -107,7 +107,7 @@ START_TEST (test_pcre_patterns_insert)
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);
ck_assert((int)matched); ck_assert(matched);
ck_assert(matched->endpoint > 0); ck_assert(matched->endpoint > 0);
// incomplete string shouldn't match // incomplete string shouldn't match
@ -273,7 +273,7 @@ START_TEST(test_pcre_pattern_simple)
// r3_tree_dump(n, 0); // r3_tree_dump(n, 0);
node *matched; node *matched;
matched = r3_tree_matchl(n, "/user/123", strlen("/user/123"), entry); matched = r3_tree_matchl(n, "/user/123", strlen("/user/123"), entry);
fail_if(matched == NULL); ck_assert(matched);
ck_assert(entry->vars->len > 0); ck_assert(entry->vars->len > 0);
ck_assert_str_eq(entry->vars->tokens[0],"123"); ck_assert_str_eq(entry->vars->tokens[0],"123");
r3_tree_free(n); r3_tree_free(n);
@ -306,7 +306,7 @@ START_TEST(test_pcre_pattern_more)
node *matched; node *matched;
matched = r3_tree_matchl(n, "/user/123", strlen("/user/123"), entry); matched = r3_tree_matchl(n, "/user/123", strlen("/user/123"), entry);
fail_if(matched == NULL); ck_assert(matched);
ck_assert(entry->vars->len > 0); ck_assert(entry->vars->len > 0);
ck_assert_str_eq(entry->vars->tokens[0],"123"); ck_assert_str_eq(entry->vars->tokens[0],"123");
@ -315,13 +315,13 @@ START_TEST(test_pcre_pattern_more)
ck_assert_int_eq( *((int*) matched->data), var1); ck_assert_int_eq( *((int*) matched->data), var1);
matched = r3_tree_matchl(n, "/user2/123", strlen("/user2/123"), entry); matched = r3_tree_matchl(n, "/user2/123", strlen("/user2/123"), entry);
fail_if(matched == NULL); ck_assert(matched);
ck_assert(entry->vars->len > 0); ck_assert(entry->vars->len > 0);
ck_assert_str_eq(entry->vars->tokens[0],"123"); ck_assert_str_eq(entry->vars->tokens[0],"123");
ck_assert_int_eq( *((int*)matched->data), var2); ck_assert_int_eq( *((int*)matched->data), var2);
matched = r3_tree_matchl(n, "/user3/123", strlen("/user3/123"), entry); matched = r3_tree_matchl(n, "/user3/123", strlen("/user3/123"), entry);
fail_if(matched == NULL); ck_assert(matched);
ck_assert(entry->vars->len > 0); ck_assert(entry->vars->len > 0);
ck_assert_str_eq(entry->vars->tokens[0],"123"); ck_assert_str_eq(entry->vars->tokens[0],"123");
ck_assert_int_eq( *((int*)matched->data), var3); ck_assert_int_eq( *((int*)matched->data), var3);