From 066280cf99c575702ab771e1b0f5319d9c3fcde1 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Thu, 22 Oct 2015 03:18:24 -0200 Subject: source-parser: handle \r\n line endings properly --- tests/check_source_parser.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests') diff --git a/tests/check_source_parser.c b/tests/check_source_parser.c index 145ba30..810786b 100644 --- a/tests/check_source_parser.c +++ b/tests/check_source_parser.c @@ -51,6 +51,37 @@ test_source_parse(void **state) } +static void +test_source_parse_crlf(void **state) +{ + const char *a = + "VAR1: asd asd\r\n" + "VAR2: 123chunda\r\n" + "----------\r\n" + "# This is a test\r\n" + "\r\n" + "bola\r\n"; + 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

\r\n" + "

bola

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

This is a test

\r\n" + "

bola

\r\n"); + assert_string_equal(b_trie_lookup(source, "RAW_CONTENT"), + "# This is a test\r\n" + "\r\n" + "bola\r\n"); + b_trie_free(source); +} + + static void test_source_parse_with_spaces(void **state) { @@ -446,6 +477,7 @@ main(void) { const UnitTest tests[] = { unit_test(test_source_parse), + unit_test(test_source_parse_crlf), unit_test(test_source_parse_with_spaces), unit_test(test_source_parse_with_excerpt), unit_test(test_source_parse_config_empty), -- cgit v1.2.3-18-g5258