summaryrefslogtreecommitdiffstats
path: root/test cases/d/14 dub with deps/test.d
blob: 61b5bdaea817627f19a72aa70e9969ac2dbe3ce1 (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
module test;

// testing import dirs
import xlsx;

// dependency of xlsx
import dxml.dom;

const xml = "<!-- comment -->\n" ~
    "<root>\n" ~
    "    <foo>some text<whatever/></foo>\n" ~
    "    <bar/>\n" ~
    "    <baz></baz>\n" ~
    "</root>";

int main()
{
    // testing versions
    version (Have_dxml)
    {
        import std.range.primitives : empty;

        auto dom = parseDOM(xml);
        assert(dom.type == EntityType.elementStart);
        assert(dom.name.empty);
        assert(dom.children.length == 2);

        assert(dom.children[0].type == EntityType.comment);
        assert(dom.children[0].text == " comment ");

        auto root = dom.children[1];
        assert(root.type == EntityType.elementStart);
        assert(root.name == "root");
        assert(root.children.length == 3);

        auto foo = root.children[0];
        assert(foo.type == EntityType.elementStart);
        assert(foo.name == "foo");
        assert(foo.children.length == 2);

        assert(foo.children[0].type == EntityType.text);
        assert(foo.children[0].text == "some text");

        assert(foo.children[1].type == EntityType.elementEmpty);
        assert(foo.children[1].name == "whatever");

        assert(root.children[1].type == EntityType.elementEmpty);
        assert(root.children[1].name == "bar");

        assert(root.children[2].type == EntityType.elementStart);
        assert(root.children[2].name == "baz");
        assert(root.children[2].children.length == 0);
        return 0;
    }
    else
    {
        return 1;
    }
}