diff options
| author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-05-04 05:40:53 -0300 | 
|---|---|---|
| committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-05-04 05:40:53 -0300 | 
| commit | 9d484725cf9874ff3f34c61af5f57f6b92e05c00 (patch) | |
| tree | b3c5b2ca63d108157ac69fe18b0ecabacf93920b /tests | |
| parent | edb7d515d6f3c41196c1dcb36d719baad1a85bc9 (diff) | |
| download | blogc-9d484725cf9874ff3f34c61af5f57f6b92e05c00.tar.gz blogc-9d484725cf9874ff3f34c61af5f57f6b92e05c00.tar.bz2 blogc-9d484725cf9874ff3f34c61af5f57f6b92e05c00.zip  | |
started implementint a markdown-like syntax for content
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/check_content_parser.c | 90 | 
1 files changed, 90 insertions, 0 deletions
diff --git a/tests/check_content_parser.c b/tests/check_content_parser.c new file mode 100644 index 0000000..86ba8d8 --- /dev/null +++ b/tests/check_content_parser.c @@ -0,0 +1,90 @@ +/* + * blogc: A blog compiler. + * Copyright (C) 2015 Rafael G. Martins <rafael@rafaelmartins.eng.br> + * + * This program can be distributed under the terms of the BSD License. + * See the file COPYING. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif /* HAVE_CONFIG_H */ + +#include <stdarg.h> +#include <stddef.h> +#include <setjmp.h> +#include <cmocka.h> +#include <string.h> +#include "../src/content-parser.h" +#include "../src/error.h" +#include "../src/utils/utils.h" + + +static void +test_content_parse(void **state) +{ +    const char *a = +        "# um\n" +        "## dois\n" +        "### tres\n" +        "#### quatro\n" +        "##### cinco\n" +        "###### seis\n" +        "\n" +        "bola\n" +        "chunda\n" +        "\n" +        ">  bola\n" +        ">  guda\n" +        ">  buga\n" +        ">  \n" +        ">    asd\n" +        "\n" +        "    bola\n" +        "     asd\n" +        "    qwewer\n" +        "\n" +        "<style>\n" +        "   chunda\n" +        "</style>\n" +        "\n" +        "guda\n" +        "yay"; +    blogc_error_t *err = NULL; +    char *html = blogc_content_parse(a, strlen(a), &err); +    assert_null(err); +    assert_non_null(html); +    assert_string_equal(html, +        "<h1>um</h1>\n" +        "<h2>dois</h2>\n" +        "<h3>tres</h3>\n" +        "<h4>quatro</h4>\n" +        "<h5>cinco</h5>\n" +        "<h6>seis</h6>\n" +        "<p>bola\n" +        "chunda</p>\n" +        "<blockquote><p>bola\n" +        "guda\n" +        "buga</p>\n" +        "<pre><code>asd</code></pre>\n" +        "</blockquote>\n" +        "<pre><code>bola\n" +        " asd\n" +        "qwewer</code></pre>\n" +        "<style>\n" +        "   chunda\n" +        "</style>\n" +        "<p>guda\n" +        "yay</p>\n"); +    free(html); +} + + +int +main(void) +{ +    const UnitTest tests[] = { +        unit_test(test_content_parse), +    }; +    return run_tests(tests); +}  | 
