diff options
| -rw-r--r-- | src/source-parser.c | 2 | ||||
| -rw-r--r-- | tests/check_source_parser.c | 32 | 
2 files changed, 34 insertions, 0 deletions
diff --git a/src/source-parser.c b/src/source-parser.c index aee5c23..db0792c 100644 --- a/src/source-parser.c +++ b/src/source-parser.c @@ -144,6 +144,8 @@ blogc_source_parse(const char *src, size_t src_len, blogc_error_t **err)                  break;              case SOURCE_CONTENT_START: +                if (c == '\n' || c == '\r') +                    break;                  start = current;                  state = SOURCE_CONTENT;                  break; 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),  | 
