Skip to content

Commit 7163b55

Browse files
committed
change @Assert to @test in parse.jl
1 parent da047e8 commit 7163b55

File tree

1 file changed

+65
-64
lines changed

1 file changed

+65
-64
lines changed

test/parse.jl

Lines changed: 65 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using MiniDOM
2+
using Base.Test
23

34
# document
45

@@ -22,116 +23,116 @@ docstr = """
2223

2324
xdoc = parse_string(docstr)
2425

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
2829

2930

3031
# root node
3132

3233
xroot = docelement(xdoc)
3334

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)
4041

4142
ras = collect(attributes(xroot))
42-
@assert isempty(ras)
43+
@test isempty(ras)
4344

4445

4546
# children of root (text nodes and books)
4647

4748
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
4950

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])
5354

54-
@assert is_elementnode(rcs[2])
55-
@assert is_elementnode(rcs[4])
55+
@test is_elementnode(rcs[2])
56+
@test is_elementnode(rcs[4])
5657

5758
xb1 = XMLElement(rcs[2])
5859

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"
6566

6667
b1as = collect(attributes(xb1))
67-
@assert length(b1as) == 2
68+
@test length(b1as) == 2
6869

6970
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"
7374

7475
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"
7879

7980
xb2 = XMLElement(rcs[4])
8081

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"
8687

8788
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"
9293

9394
# child elements of book[1]
9495

9596
ces = collect(child_elements(xb1))
9697

97-
@assert length(ces) == 4
98+
@test length(ces) == 4
9899
c1, c2, c3, c4 = ces[1], ces[2], ces[3], ces[4]
99100

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"
105106

106-
@assert has_children(c1)
107+
@test has_children(c1)
107108
c1cs = collect(child_nodes(c1))
108-
@assert length(c1cs) == 1
109+
@test length(c1cs) == 1
109110
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"
112113

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"
117118

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"
122123

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"
127128

128129
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"
132133

133134
cz = find_element(xb1, "abc")
134-
@assert is(cz, nothing)
135+
@test is(cz, nothing)
135136

136137
free(xdoc)
137138

0 commit comments

Comments
 (0)