diff options
| author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-04-19 14:36:19 -0300 | 
|---|---|---|
| committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-04-19 14:36:19 -0300 | 
| commit | b81e0c2b1c70badf4131cf8a587a06e1c31df1f5 (patch) | |
| tree | 1b6099808b8d762120fb5742c4edff6e5adfc198 /tests | |
| parent | d301477f1aba66d5f0996da7a610e703d34837c1 (diff) | |
| download | blogc-b81e0c2b1c70badf4131cf8a587a06e1c31df1f5.tar.gz blogc-b81e0c2b1c70badf4131cf8a587a06e1c31df1f5.tar.bz2 blogc-b81e0c2b1c70badf4131cf8a587a06e1c31df1f5.zip  | |
loader: added compiler-defined variables
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/check_loader.c | 58 | 
1 files changed, 58 insertions, 0 deletions
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 <rafael@rafaelmartins.eng.br> + * + * This program can be distributed under the terms of the BSD License. + * See the file COPYING. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif /* HAVE_CONFIG_H */ + +#include <stdarg.h> +#include <stddef.h> +#include <setjmp.h> +#include <cmocka.h> +#include <string.h> +#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); +}  | 
