From 3aeccf252c8c266b51c1a2cc1dc9e9e3d5bf2f90 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Sat, 13 Jun 2015 03:32:21 -0300 Subject: content-parser: implemented excerpt, and now for good! --- tests/check_source_parser.c | 54 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) (limited to 'tests/check_source_parser.c') 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"), + "

This is a test

\n" + "

bola

\n"); assert_string_equal(b_trie_lookup(source, "CONTENT"), "

This is a test

\n" "

bola

\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"), + "

This is a test

\n" + "

bola

\n"); assert_string_equal(b_trie_lookup(source, "CONTENT"), "

This is a test

\n" "

bola

\n"); @@ -78,6 +84,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"), + "

This is a test

\n" + "

bola

\n"); + assert_string_equal(b_trie_lookup(source, "CONTENT"), + "

This is a test

\n" + "

bola

\n" + "

guda\n" + "yay

\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) { @@ -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), -- cgit v1.2.3-18-g5258