aboutsummaryrefslogtreecommitdiffstats
path: root/tests/check_source_parser.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2015-06-13 03:32:21 -0300
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2015-06-13 03:32:21 -0300
commit3aeccf252c8c266b51c1a2cc1dc9e9e3d5bf2f90 (patch)
treebc7a75a51d2fbf180c9d63ee1164b93ca21b9b6f /tests/check_source_parser.c
parent168de93a068e489eb96c541172de5e43e13a5873 (diff)
downloadblogc-3aeccf252c8c266b51c1a2cc1dc9e9e3d5bf2f90.tar.gz
blogc-3aeccf252c8c266b51c1a2cc1dc9e9e3d5bf2f90.tar.bz2
blogc-3aeccf252c8c266b51c1a2cc1dc9e9e3d5bf2f90.zip
content-parser: implemented excerpt, and now for good!
Diffstat (limited to 'tests/check_source_parser.c')
-rw-r--r--tests/check_source_parser.c54
1 files changed, 52 insertions, 2 deletions
diff --git a/tests/check_source_parser.c b/tests/check_source_parser.c
index 0cec364..79ca10f 100644
--- a/tests/check_source_parser.c
+++ b/tests/check_source_parser.c
@@ -34,9 +34,12 @@ test_source_parse(void **state)
b_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_null(err);
assert_non_null(source);
- assert_int_equal(b_trie_size(source), 4);
+ assert_int_equal(b_trie_size(source), 5);
assert_string_equal(b_trie_lookup(source, "VAR1"), "asd asd");
assert_string_equal(b_trie_lookup(source, "VAR2"), "123chunda");
+ assert_string_equal(b_trie_lookup(source, "EXCERPT"),
+ "<h1>This is a test</h1>\n"
+ "<p>bola</p>\n");
assert_string_equal(b_trie_lookup(source, "CONTENT"),
"<h1>This is a test</h1>\n"
"<p>bola</p>\n");
@@ -64,9 +67,12 @@ test_source_parse_with_spaces(void **state)
b_trie_t *source = blogc_source_parse(a, strlen(a), &err);
assert_null(err);
assert_non_null(source);
- assert_int_equal(b_trie_size(source), 4);
+ assert_int_equal(b_trie_size(source), 5);
assert_string_equal(b_trie_lookup(source, "VAR1"), "chunda");
assert_string_equal(b_trie_lookup(source, "BOLA"), "guda");
+ assert_string_equal(b_trie_lookup(source, "EXCERPT"),
+ "<h1>This is a test</h1>\n"
+ "<p>bola</p>\n");
assert_string_equal(b_trie_lookup(source, "CONTENT"),
"<h1>This is a test</h1>\n"
"<p>bola</p>\n");
@@ -79,6 +85,49 @@ test_source_parse_with_spaces(void **state)
static void
+test_source_parse_with_excerpt(void **state)
+{
+ const char *a =
+ "VAR1: asd asd\n"
+ "VAR2: 123chunda\n"
+ "----------\n"
+ "# This is a test\n"
+ "\n"
+ "bola\n"
+ "\n"
+ "...\n"
+ "\n"
+ "guda\n"
+ "yay";
+ blogc_error_t *err = NULL;
+ b_trie_t *source = blogc_source_parse(a, strlen(a), &err);
+ assert_null(err);
+ assert_non_null(source);
+ assert_int_equal(b_trie_size(source), 5);
+ assert_string_equal(b_trie_lookup(source, "VAR1"), "asd asd");
+ assert_string_equal(b_trie_lookup(source, "VAR2"), "123chunda");
+ assert_string_equal(b_trie_lookup(source, "EXCERPT"),
+ "<h1>This is a test</h1>\n"
+ "<p>bola</p>\n");
+ assert_string_equal(b_trie_lookup(source, "CONTENT"),
+ "<h1>This is a test</h1>\n"
+ "<p>bola</p>\n"
+ "<p>guda\n"
+ "yay</p>\n");
+ assert_string_equal(b_trie_lookup(source, "RAW_CONTENT"),
+ "# This is a test\n"
+ "\n"
+ "bola\n"
+ "\n"
+ "...\n"
+ "\n"
+ "guda\n"
+ "yay");
+ b_trie_free(source);
+}
+
+
+static void
test_source_parse_config_empty(void **state)
{
const char *a = "";
@@ -381,6 +430,7 @@ main(void)
const UnitTest tests[] = {
unit_test(test_source_parse),
unit_test(test_source_parse_with_spaces),
+ unit_test(test_source_parse_with_excerpt),
unit_test(test_source_parse_config_empty),
unit_test(test_source_parse_config_invalid_key),
unit_test(test_source_parse_config_no_key),