blob: 86ba8d89ed829f50496ce62629382332543d7340 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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);
}
|