diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-04-15 23:41:42 -0300 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-04-15 23:57:18 -0300 |
commit | 63602a4fcf3e811e529ed5b7ba670764d29fc96b (patch) | |
tree | 08d38e640ac2698edbe840d0fb1db40368012717 /tests/check_source_grammar.c | |
parent | a3c06fb8f19df6ef612cf2d647d75f8c2bedca8b (diff) | |
download | blogc-63602a4fcf3e811e529ed5b7ba670764d29fc96b.tar.gz blogc-63602a4fcf3e811e529ed5b7ba670764d29fc96b.tar.bz2 blogc-63602a4fcf3e811e529ed5b7ba670764d29fc96b.zip |
added source grammar
Diffstat (limited to 'tests/check_source_grammar.c')
-rw-r--r-- | tests/check_source_grammar.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/check_source_grammar.c b/tests/check_source_grammar.c new file mode 100644 index 0000000..a80be8e --- /dev/null +++ b/tests/check_source_grammar.c @@ -0,0 +1,49 @@ +/* + * 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 "../src/source-grammar.h" + + +static void +test_source_parse(void **state) +{ + blogc_source_t *source = blogc_source_parse( + "VAR1: asd asd\n" + "VAR2: 123chunda\n" + "----------\n" + "# This is a test\n" + "\n" + "bola\n"); + assert_non_null(source); + assert_int_equal(b_trie_size(source->config), 2); + assert_string_equal(b_trie_lookup(source->config, "VAR1"), "asd asd"); + assert_string_equal(b_trie_lookup(source->config, "VAR2"), "123chunda"); + assert_string_equal(source->content, + "# This is a test\n" + "\n" + "bola\n"); + blogc_source_free(source); +} + + +int +main(void) +{ + const UnitTest tests[] = { + unit_test(test_source_parse), + }; + return run_tests(tests); +} |