diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-10-22 03:18:24 -0200 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-10-22 03:18:24 -0200 |
commit | 066280cf99c575702ab771e1b0f5319d9c3fcde1 (patch) | |
tree | 13f5893de3258654085b1e58dac8f339d370e8c8 /tests | |
parent | 908fc8266ef81f80964be710dd5a15dbdb86500f (diff) | |
download | blogc-066280cf99c575702ab771e1b0f5319d9c3fcde1.tar.gz blogc-066280cf99c575702ab771e1b0f5319d9c3fcde1.tar.bz2 blogc-066280cf99c575702ab771e1b0f5319d9c3fcde1.zip |
source-parser: handle \r\n line endings properly
Diffstat (limited to 'tests')
-rw-r--r-- | tests/check_source_parser.c | 32 |
1 files changed, 32 insertions, 0 deletions
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 @@ -52,6 +52,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"), + "<h1 id=\"this-is-a-test\">This is a test</h1>\r\n" + "<p>bola</p>\r\n"); + assert_string_equal(b_trie_lookup(source, "CONTENT"), + "<h1 id=\"this-is-a-test\">This is a test</h1>\r\n" + "<p>bola</p>\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) { const char *a = @@ -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), |