From b81e0c2b1c70badf4131cf8a587a06e1c31df1f5 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Sun, 19 Apr 2015 14:36:19 -0300 Subject: loader: added compiler-defined variables --- tests/check_loader.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tests/check_loader.c (limited to 'tests/check_loader.c') diff --git a/tests/check_loader.c b/tests/check_loader.c new file mode 100644 index 0000000..c9f1432 --- /dev/null +++ b/tests/check_loader.c @@ -0,0 +1,58 @@ +/* + * blogc: A blog compiler. + * Copyright (C) 2015 Rafael G. Martins + * + * This program can be distributed under the terms of the BSD License. + * See the file COPYING. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif /* HAVE_CONFIG_H */ + +#include +#include +#include +#include +#include +#include "../src/loader.h" + + +static void +test_get_filename(void **state) +{ + char *f = blogc_get_filename("/home/foo/asd/bola.txt"); + assert_string_equal(f, "bola"); + free(f); + f = blogc_get_filename("/home/foo/asd/bola.guda.txt"); + assert_string_equal(f, "bola.guda"); + free(f); + f = blogc_get_filename("bola.txt"); + assert_string_equal(f, "bola"); + free(f); + f = blogc_get_filename("bola.guda.txt"); + assert_string_equal(f, "bola.guda"); + free(f); + f = blogc_get_filename("/home/foo/asd/bola"); + assert_string_equal(f, "bola"); + free(f); + f = blogc_get_filename("bola"); + assert_string_equal(f, "bola"); + free(f); + f = blogc_get_filename(""); + assert_null(f); + free(f); + f = blogc_get_filename(NULL); + assert_null(f); + free(f); +} + + +int +main(void) +{ + const UnitTest tests[] = { + unit_test(test_get_filename), + }; + return run_tests(tests); +} -- cgit v1.2.3-18-g5258