check_slug: free memory

This commit is contained in:
c9s 2014-05-21 18:50:45 +08:00
parent 05b698b841
commit 79fb3a3b8a

View file

@ -15,16 +15,21 @@
START_TEST (test_slug_compile) START_TEST (test_slug_compile)
{ {
char * path = "/user/{id}"; char * path = "/user/{id}";
ck_assert_str_eq( slug_compile(path, strlen(path) ) , "/user/([^/]+)" ); char * c = NULL;
ck_assert_str_eq( c = slug_compile(path, strlen(path) ) , "/user/([^/]+)" );
zfree(c);
char * path2 = "/what/{id}-foo"; char * path2 = "/what/{id}-foo";
ck_assert_str_eq( slug_compile(path2, strlen(path2) ) , "/what/([^/]+)-foo" ); ck_assert_str_eq( c = slug_compile(path2, strlen(path2) ) , "/what/([^/]+)-foo" );
zfree(c);
char * path3 = "-{id}"; char * path3 = "-{id}";
ck_assert_str_eq(slug_compile(path3, strlen(path3)), "-([^/]+)" ); ck_assert_str_eq( c = slug_compile(path3, strlen(path3)), "-([^/]+)" );
zfree(c);
char * path4 = "-{idx:\\d{3}}"; char * path4 = "-{idx:\\d{3}}";
ck_assert_str_eq(slug_compile(path4, strlen(path4)), "-(\\d{3})" ); ck_assert_str_eq( c = slug_compile(path4, strlen(path4)), "-(\\d{3})" );
zfree(c);
} }
END_TEST END_TEST