Debian Codegraph @

test cases/d/14 dub with deps/test.d

raw
1 module test;
2
3 // testing import dirs
4 import xlsx;
5
6 // dependency of xlsx
7 import dxml.dom;
8
9 const xml = "<!-- comment -->\n" ~
10 "<root>\n" ~
11 " <foo>some text<whatever/></foo>\n" ~
12 " <bar/>\n" ~
13 " <baz></baz>\n" ~
14 "</root>";
15
16 int main()
17 {
18 // testing versions
19 version (Have_dxml)
20 {
21 import std.range.primitives : empty;
22
23 auto dom = parseDOM(xml);
24 assert(dom.type == EntityType.elementStart);
25 assert(dom.name.empty);
26 assert(dom.children.length == 2);
27
28 assert(dom.children[0].type == EntityType.comment);
29 assert(dom.children[0].text == " comment ");
30
31 auto root = dom.children[1];
32 assert(root.type == EntityType.elementStart);
33 assert(root.name == "root");
34 assert(root.children.length == 3);
35
36 auto foo = root.children[0];
37 assert(foo.type == EntityType.elementStart);
38 assert(foo.name == "foo");
39 assert(foo.children.length == 2);
40
41 assert(foo.children[0].type == EntityType.text);
42 assert(foo.children[0].text == "some text");
43
44 assert(foo.children[1].type == EntityType.elementEmpty);
45 assert(foo.children[1].name == "whatever");
46
47 assert(root.children[1].type == EntityType.elementEmpty);
48 assert(root.children[1].name == "bar");
49
50 assert(root.children[2].type == EntityType.elementStart);
51 assert(root.children[2].name == "baz");
52 assert(root.children[2].children.length == 0);
53 return 0;
54 }
55 else
56 {
57 return 1;
58 }
59 }