-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtml_parser_attribute_reader_test.c
More file actions
70 lines (51 loc) · 1.59 KB
/
Copy pathhtml_parser_attribute_reader_test.c
File metadata and controls
70 lines (51 loc) · 1.59 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
#include <string.h>
#include "html_parser_assert.h"
#include "html_parser_mem.h"
#include "html_parser_fmt.h"
#include "html_parser_text.h"
#include "html_parser_attribute_rep.h"
#include "html_parser_attribute_list.h"
#include "html_parser_attribute_reader.h"
#include "html_parser_tester.h"
#define T Test_T
#define ATTR_LIST_SIZE 3
/* test data */
/* test functions */
static int Test_attribute_list_reader(T t, void *, const void *);
int main(int argc, const char *argv[])
{
Test_T suite;
char *attrs[ATTR_LIST_SIZE] = {
"body id=\"genre\"",
"title=\"Eternally Yours\"",
"rel=\"stylesheet\" type=\"text/css\" href=\"https://d11xdyzr0div58.cloudfront.net/static/archweb.78c17bb7e94a.css\" media=\"screen, projection\" title=\"Arch Linux Packages\""
};
Fmt_fprint(stderr, "==> Starting %s <==\n", __FILE__);
suite = Test_init();
Test_add(suite, Test_attribute_list_reader, NULL, (const void *) attrs);
Test_all_run(suite);
Test_print_results(suite);
Test_free(&suite);
return 0;
}
static int Test_attribute_list_reader(T t, void *s, const void *chk)
{
char **attrs = (char **) chk;
Text_T fout = Text_box("", 0);
Fmt_register('T', Text_fmt);
for(int i = 0; i < ATTR_LIST_SIZE; i++) {
char *lr;
Attr_list_T head = Attr_list_list();
Text_T tmp = Text_put(attrs[i]);
head = Attribute_reader(&tmp);
lr = (char *) Attr_list_print(head);
fout = Text_cat(fout, Text_put(lr));
fout = Text_cat(fout, Text_put("\n"));
FREE(lr);
Attr_list_free(&head);
}
fout = Text_sub(fout, 1, -2);
TEST_FUNC_NAME(t);
TEST_FUNC_OUT(t, Fmt_string("%T", &fout));
return TEST_SUCCESS;
}