-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtml_parser_document_builder_test.c
More file actions
79 lines (58 loc) · 1.8 KB
/
Copy pathhtml_parser_document_builder_test.c
File metadata and controls
79 lines (58 loc) · 1.8 KB
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
#include "html_parser_assert.h"
#include "html_parser_mem.h"
#include "html_parser_fmt.h"
#include "html_parser_text.h"
#include "html_parser_file_reader.h"
#include "html_parser_types.h"
#include "html_parser_document_node.h"
#include "html_parser_document_tree.h"
#include "html_parser_document_builder.h"
#include "html_parser_tester.h"
#define T Test_T
/* test data */
/* test functions */
static int Test_doc_build_sieve(T t, void *, const void *);
static int Test_doc_build_builder(T t, void *, const void *);
int main(int argc, const char *argv[])
{
T suite;
Fmt_fprint(stderr, "==> Starting %s <==\n", __FILE__);
suite = Test_init();
Test_add(suite, Test_doc_build_sieve, NULL, NULL);
Test_add(suite, Test_doc_build_builder, NULL, NULL);
Test_all_run(suite);
Test_print_results(suite);
Test_free(&suite);
return 0;
}
static int Test_doc_build_sieve(T t, void *s, const void *chk)
{
Chunk_E f;
Text_T chunk;
Text_T doc = File_reader_reader("/home/joe/programming/c/html_parser/data/doc_build_sieve_test.html", NULL);
/*Text_T doc = File_reader_reader("data/arni.html", NULL);*/
while (doc.len > 0) {
f = Doc_builder_sieve(&doc, &chunk);
if (!(f & C_CNTMT)) {
Fmt_fprint(stderr, "\033[32m%s\033[m => '%T'\n",
Chunk_type_rep(f), &chunk);
}
}
TEST_FUNC_NAME(t);
return TEST_SUCCESS;
}
static int Test_doc_build_builder(T t, void *s, const void *chk)
{
Doc_tree_T tr;
char *str;
/*Text_T doc = File_reader_reader("data/file_reader_test.html", NULL);*/
Text_T doc = File_reader_reader("data/doc_build_sieve_test.html", NULL);
/*Text_T doc = File_reader_reader("data/arni.html", NULL);*/
tr = Doc_builder_builder(doc);
TEST_FUNC_NAME(t);
/*TEST_FUNC_OUT(t, Doc_tree_print(*dt));*/
Fmt_fprint(stdout, "==========\n");
Doc_tree_print(tr);
// Doc_tree_free(dt);
return TEST_FAIL;
}