Skip to content

Commit 9a59ec5

Browse files
committed
Refactor tests
1 parent 262a19d commit 9a59ec5

File tree

1 file changed

+78
-75
lines changed

1 file changed

+78
-75
lines changed

test/runtests.jl

Lines changed: 78 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -31,86 +31,89 @@ for (test, str) in TEST_STRINGS
3131
end
3232

3333
@testset "BlockScalars.jl" begin
34-
@testset "block: $test" for (test, str) in TEST_STRINGS
35-
expected_lk = yaml_block(str, "|+")
36-
expected_lc = yaml_block(str, "|")
37-
expected_ls = yaml_block(str, "|-")
38-
39-
expected_fk = yaml_block(str, ">+")
40-
expected_fc = yaml_block(str, ">")
41-
expected_fs = yaml_block(str, ">-")
42-
43-
@testset "literal" begin
44-
@test block(str, :literal, :keep) == expected_lk
45-
@test block(str, :literal, :clip) == expected_lc
46-
@test block(str, :literal, :strip) == expected_ls
47-
48-
@test block(str, style=:literal, chomp=:keep) == expected_lk
49-
@test block(str, style=:literal, chomp=:clip) == expected_lc
50-
@test block(str, style=:literal, chomp=:strip) == expected_ls
51-
52-
@test block(str, "lk") == expected_lk
53-
@test block(str, "lc") == expected_lc
54-
@test block(str, "ls") == expected_ls
55-
56-
@test block(str, "|+") == expected_lk
57-
@test block(str, "|-") == expected_ls
34+
@testset "block" begin
35+
@testset "string: $test" for (test, str) in TEST_STRINGS
36+
expected_lk = yaml_block(str, "|+")
37+
expected_lc = yaml_block(str, "|")
38+
expected_ls = yaml_block(str, "|-")
39+
40+
expected_fk = yaml_block(str, ">+")
41+
expected_fc = yaml_block(str, ">")
42+
expected_fs = yaml_block(str, ">-")
43+
44+
@testset "literal" begin
45+
@test block(str, :literal, :keep) == expected_lk
46+
@test block(str, :literal, :clip) == expected_lc
47+
@test block(str, :literal, :strip) == expected_ls
48+
49+
@test block(str, style=:literal, chomp=:keep) == expected_lk
50+
@test block(str, style=:literal, chomp=:clip) == expected_lc
51+
@test block(str, style=:literal, chomp=:strip) == expected_ls
52+
53+
@test block(str, "lk") == expected_lk
54+
@test block(str, "lc") == expected_lc
55+
@test block(str, "ls") == expected_ls
56+
57+
@test block(str, "|+") == expected_lk
58+
@test block(str, "|-") == expected_ls
59+
end
60+
61+
@testset "folding" begin
62+
@test block(str, :folded, :keep) == expected_fk
63+
@test block(str, :folded, :clip) == expected_fc
64+
@test block(str, :folded, :strip) == expected_fs
65+
66+
@test block(str, style=:folded, chomp=:keep) == expected_fk
67+
@test block(str, style=:folded, chomp=:clip) == expected_fc
68+
@test block(str, style=:folded, chomp=:strip) == expected_fs
69+
70+
@test block(str, "fk") == expected_fk
71+
@test block(str, "fc") == expected_fc
72+
@test block(str, "fs") == expected_fs
73+
74+
@test block(str, ">+") == expected_fk
75+
@test block(str, ">-") == expected_fs
76+
end
77+
78+
@testset "default chomp" begin
79+
@test block(str, style=:literal) == expected_ls
80+
@test block(str, style=:folded) == expected_fs
81+
82+
@test block(str, "l") == expected_ls
83+
@test block(str, "f") == expected_fs
84+
85+
@test block(str, "|") == expected_lc
86+
@test block(str, ">") == expected_fc
87+
end
88+
89+
@testset "default style" begin
90+
@test block(str, chomp=:keep) == expected_fk
91+
@test block(str, chomp=:clip) == expected_fc
92+
@test block(str, chomp=:strip) == expected_fs
93+
94+
@test block(str, "k") == expected_fk
95+
@test block(str, "c") == expected_fc
96+
@test block(str, "s") == expected_fs
97+
98+
@test block(str, "+") == expected_fk
99+
@test block(str, "-") == expected_fs
100+
end
101+
102+
@testset "default style/chomp" begin
103+
@test block(str) == expected_fs
104+
@test block(str, "") == expected_fs
105+
end
58106
end
59107

60-
@testset "folding" begin
61-
@test block(str, :folded, :keep) == expected_fk
62-
@test block(str, :folded, :clip) == expected_fc
63-
@test block(str, :folded, :strip) == expected_fs
64-
65-
@test block(str, style=:folded, chomp=:keep) == expected_fk
66-
@test block(str, style=:folded, chomp=:clip) == expected_fc
67-
@test block(str, style=:folded, chomp=:strip) == expected_fs
68-
69-
@test block(str, "fk") == expected_fk
70-
@test block(str, "fc") == expected_fc
71-
@test block(str, "fs") == expected_fs
72-
73-
@test block(str, ">+") == expected_fk
74-
@test block(str, ">-") == expected_fs
75-
end
76-
77-
@testset "default chomp" begin
78-
@test block(str, style=:literal) == expected_ls
79-
@test block(str, style=:folded) == expected_fs
80-
81-
@test block(str, "l") == expected_ls
82-
@test block(str, "f") == expected_fs
83-
84-
@test block(str, "|") == expected_lc
85-
@test block(str, ">") == expected_fc
86-
end
87-
88-
@testset "default style" begin
89-
@test block(str, chomp=:keep) == expected_fk
90-
@test block(str, chomp=:clip) == expected_fc
91-
@test block(str, chomp=:strip) == expected_fs
92-
93-
@test block(str, "k") == expected_fk
94-
@test block(str, "c") == expected_fc
95-
@test block(str, "s") == expected_fs
96-
97-
@test block(str, "+") == expected_fk
98-
@test block(str, "-") == expected_fs
99-
end
100-
101-
@testset "default style/chomp" begin
102-
@test block(str) == expected_fs
103-
@test block(str, "") == expected_fs
108+
@testset "invalid indicators" begin
109+
@test_throws ArgumentError block("", "fs_") # Too many indicators
110+
@test_throws ArgumentError block("", "sf") # Order matters
111+
@test_throws ArgumentError block("", "_s") # Invalid style
112+
@test_throws ArgumentError block("", "f_") # Invalid chomp
113+
@test_throws ArgumentError block("", "_") # Invalid style/chomp
104114
end
105115
end
106116

107-
# @testset "block invalid indicator" begin
108-
# @test_throws ArgumentError block("", "fs_") # Too many indicators
109-
# @test_throws ArgumentError block("", "sf") # Order matters
110-
# @test_throws ArgumentError block("", "_s") # Invalid style
111-
# @test_throws ArgumentError block("", "f_") # Invalid chomp
112-
# @test_throws ArgumentError block("", "_") # Invalid style/chomp
113-
# end
114117

115118
@testset "@blk_str" begin
116119
@testset "invalid indicators" begin

0 commit comments

Comments
 (0)