2014-05-14 12:15:19 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <check.h>
|
2014-05-14 22:08:42 -04:00
|
|
|
#include "str.h"
|
|
|
|
#include "node.h"
|
2014-05-14 23:52:45 -04:00
|
|
|
#include "token.h"
|
2014-05-14 12:15:19 -04:00
|
|
|
|
2014-05-14 22:08:42 -04:00
|
|
|
START_TEST (test_route)
|
2014-05-14 12:15:19 -04:00
|
|
|
{
|
2014-05-14 23:52:45 -04:00
|
|
|
split_route_pattern("/blog", strlen("/blog") );
|
|
|
|
split_route_pattern("/foo/{id}", strlen("/foo/{id}") );
|
|
|
|
split_route_pattern("/{title}", strlen("/{title}") );
|
2014-05-14 22:08:42 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2014-05-14 23:52:45 -04:00
|
|
|
START_TEST (test_token_list)
|
2014-05-14 22:08:42 -04:00
|
|
|
{
|
2014-05-14 23:52:45 -04:00
|
|
|
token_list * l = token_list_create(10);
|
|
|
|
fail_if( l == NULL );
|
|
|
|
fail_if( FALSE == token_list_resize(l, l->cap * 2) );
|
2014-05-14 22:08:42 -04:00
|
|
|
|
2014-05-14 23:52:45 -04:00
|
|
|
fail_if( FALSE == token_list_append(l, strdup("abc") ) );
|
|
|
|
fail_if( FALSE == token_list_append(l, strdup("foo") ) );
|
|
|
|
fail_if( FALSE == token_list_append(l, strdup("bar") ) );
|
|
|
|
|
|
|
|
token_list_free(l);
|
2014-05-14 12:15:19 -04:00
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2014-05-14 22:08:42 -04:00
|
|
|
Suite* r3_suite (void) {
|
|
|
|
Suite *suite = suite_create("blah");
|
|
|
|
|
|
|
|
TCase *tcase = tcase_create("testcase");
|
|
|
|
tcase_add_test(tcase, test_route);
|
2014-05-14 23:52:45 -04:00
|
|
|
tcase_add_test(tcase, test_token_list);
|
2014-05-14 12:15:19 -04:00
|
|
|
|
|
|
|
suite_add_tcase(suite, tcase);
|
2014-05-14 22:08:42 -04:00
|
|
|
|
2014-05-14 12:15:19 -04:00
|
|
|
return suite;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main (int argc, char *argv[]) {
|
|
|
|
int number_failed;
|
2014-05-14 22:08:42 -04:00
|
|
|
Suite *suite = r3_suite();
|
2014-05-14 12:15:19 -04:00
|
|
|
SRunner *runner = srunner_create(suite);
|
|
|
|
srunner_run_all(runner, CK_NORMAL);
|
|
|
|
number_failed = srunner_ntests_failed(runner);
|
|
|
|
srunner_free(runner);
|
|
|
|
return number_failed;
|
|
|
|
}
|