1
1
using MiniDOM
2
+ using Base. Test
2
3
3
4
# document
4
5
@@ -22,116 +23,116 @@ docstr = """
22
23
23
24
xdoc = parse_string (docstr)
24
25
25
- @assert version (xdoc) == " 1.0"
26
- @assert encoding (xdoc) == " UTF-8"
27
- @assert standalone (xdoc) == - 2
26
+ @test version (xdoc) == " 1.0"
27
+ @test encoding (xdoc) == " UTF-8"
28
+ @test standalone (xdoc) == - 2
28
29
29
30
30
31
# root node
31
32
32
33
xroot = docelement (xdoc)
33
34
34
- @assert isa (xroot, XMLElement)
35
- @assert is_elementnode (xroot)
36
- @assert name (xroot) == " bookstore"
37
- @assert nodetype (xroot) == 1
38
- @assert ! has_attributes (xroot)
39
- @assert has_children (xroot)
35
+ @test isa (xroot, XMLElement)
36
+ @test is_elementnode (xroot)
37
+ @test name (xroot) == " bookstore"
38
+ @test nodetype (xroot) == 1
39
+ @test ! has_attributes (xroot)
40
+ @test has_children (xroot)
40
41
41
42
ras = collect (attributes (xroot))
42
- @assert isempty (ras)
43
+ @test isempty (ras)
43
44
44
45
45
46
# children of root (text nodes and books)
46
47
47
48
rcs = collect (child_nodes (xroot))
48
- @assert length (rcs) == 5 # text, book[1], text, book[1], text
49
+ @test length (rcs) == 5 # text, book[1], text, book[1], text
49
50
50
- @assert is_textnode (rcs[1 ])
51
- @assert is_textnode (rcs[3 ])
52
- @assert is_textnode (rcs[5 ])
51
+ @test is_textnode (rcs[1 ])
52
+ @test is_textnode (rcs[3 ])
53
+ @test is_textnode (rcs[5 ])
53
54
54
- @assert is_elementnode (rcs[2 ])
55
- @assert is_elementnode (rcs[4 ])
55
+ @test is_elementnode (rcs[2 ])
56
+ @test is_elementnode (rcs[4 ])
56
57
57
58
xb1 = XMLElement (rcs[2 ])
58
59
59
- @assert name (xb1) == " book"
60
- @assert nodetype (xb1) == 1
61
- @assert has_attributes (xb1)
62
- @assert has_children (xb1)
63
- @assert attribute (xb1, " category" ) == " COOKING"
64
- @assert attribute (xb1, " tag" ) == " first"
60
+ @test name (xb1) == " book"
61
+ @test nodetype (xb1) == 1
62
+ @test has_attributes (xb1)
63
+ @test has_children (xb1)
64
+ @test attribute (xb1, " category" ) == " COOKING"
65
+ @test attribute (xb1, " tag" ) == " first"
65
66
66
67
b1as = collect (attributes (xb1))
67
- @assert length (b1as) == 2
68
+ @test length (b1as) == 2
68
69
69
70
b1a1 = b1as[1 ]
70
- @assert isa (b1a1, XMLAttr)
71
- @assert name (b1a1) == " category"
72
- @assert value (b1a1) == " COOKING"
71
+ @test isa (b1a1, XMLAttr)
72
+ @test name (b1a1) == " category"
73
+ @test value (b1a1) == " COOKING"
73
74
74
75
b1a2 = b1as[2 ]
75
- @assert isa (b1a2, XMLAttr)
76
- @assert name (b1a2) == " tag"
77
- @assert value (b1a2) == " first"
76
+ @test isa (b1a2, XMLAttr)
77
+ @test name (b1a2) == " tag"
78
+ @test value (b1a2) == " first"
78
79
79
80
xb2 = XMLElement (rcs[4 ])
80
81
81
- @assert name (xb2) == " book"
82
- @assert nodetype (xb2) == 1
83
- @assert has_attributes (xb2)
84
- @assert has_children (xb2)
85
- @assert attribute (xb2, " category" ) == " CHILDREN"
82
+ @test name (xb2) == " book"
83
+ @test nodetype (xb2) == 1
84
+ @test has_attributes (xb2)
85
+ @test has_children (xb2)
86
+ @test attribute (xb2, " category" ) == " CHILDREN"
86
87
87
88
rces = get_elements_by_tagname (xroot, " book" )
88
- @assert length (rces) == 2
89
- @assert isa (rces, Vector{XMLElement})
90
- @assert attribute (rces[1 ], " category" ) == " COOKING"
91
- @assert attribute (rces[2 ], " category" ) == " CHILDREN"
89
+ @test length (rces) == 2
90
+ @test isa (rces, Vector{XMLElement})
91
+ @test attribute (rces[1 ], " category" ) == " COOKING"
92
+ @test attribute (rces[2 ], " category" ) == " CHILDREN"
92
93
93
94
# child elements of book[1]
94
95
95
96
ces = collect (child_elements (xb1))
96
97
97
- @assert length (ces) == 4
98
+ @test length (ces) == 4
98
99
c1, c2, c3, c4 = ces[1 ], ces[2 ], ces[3 ], ces[4 ]
99
100
100
- @assert isa (c1, XMLElement)
101
- @assert name (c1) == " title"
102
- @assert has_attributes (c1)
103
- @assert attribute (c1, " lang" ) == " en"
104
- @assert content (c1) == " Everyday Italian"
101
+ @test isa (c1, XMLElement)
102
+ @test name (c1) == " title"
103
+ @test has_attributes (c1)
104
+ @test attribute (c1, " lang" ) == " en"
105
+ @test content (c1) == " Everyday Italian"
105
106
106
- @assert has_children (c1)
107
+ @test has_children (c1)
107
108
c1cs = collect (child_nodes (c1))
108
- @assert length (c1cs) == 1
109
+ @test length (c1cs) == 1
109
110
c1c = c1cs[1 ]
110
- @assert is_textnode (c1c)
111
- @assert content (c1c) == " Everyday Italian"
111
+ @test is_textnode (c1c)
112
+ @test content (c1c) == " Everyday Italian"
112
113
113
- @assert isa (c2, XMLElement)
114
- @assert name (c2) == " author"
115
- @assert ! has_attributes (c2)
116
- @assert content (c2) == " Giada De Laurentiis"
114
+ @test isa (c2, XMLElement)
115
+ @test name (c2) == " author"
116
+ @test ! has_attributes (c2)
117
+ @test content (c2) == " Giada De Laurentiis"
117
118
118
- @assert isa (c3, XMLElement)
119
- @assert name (c3) == " year"
120
- @assert ! has_attributes (c3)
121
- @assert content (c3) == " 2005"
119
+ @test isa (c3, XMLElement)
120
+ @test name (c3) == " year"
121
+ @test ! has_attributes (c3)
122
+ @test content (c3) == " 2005"
122
123
123
- @assert isa (c4, XMLElement)
124
- @assert name (c4) == " price"
125
- @assert ! has_attributes (c4)
126
- @assert content (c4) == " 30.00"
124
+ @test isa (c4, XMLElement)
125
+ @test name (c4) == " price"
126
+ @test ! has_attributes (c4)
127
+ @test content (c4) == " 30.00"
127
128
128
129
cy = find_element (xb1, " year" )
129
- @assert isa (cy, XMLElement)
130
- @assert name (cy) == " year"
131
- @assert content (cy) == " 2005"
130
+ @test isa (cy, XMLElement)
131
+ @test name (cy) == " year"
132
+ @test content (cy) == " 2005"
132
133
133
134
cz = find_element (xb1, " abc" )
134
- @assert is (cz, nothing )
135
+ @test is (cz, nothing )
135
136
136
137
free (xdoc)
137
138
0 commit comments