Skip to content

Commit

Permalink
Further tests cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
quinnj committed Aug 29, 2016
1 parent 82a9345 commit 7786cd3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 60 deletions.
35 changes: 4 additions & 31 deletions test/11_array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,30 +146,16 @@ for (A, V, M) in ((NominalArray, NominalVector, NominalMatrix),
@test length(x) == 6
@test x[1] == x[end]
@test levels(x) == ["e", "a", "b", "c", "zz"]
# ["c", "a", "a", "a", "zz", "c"]

append!(x, x)
@test length(x) == 12
@test x[1] == "c"
@test x[2] == "a"
@test x[3] == "a"
@test x[4] == "a"
@test x[5] == "zz"
@test x[6] == "c"
@test x[7] == "c"
@test x[8] == "a"
@test x[9] == "a"
@test x[10] == "a"
@test x[11] == "zz"
@test x[12] == "c"
@test x == ["c", "a", "a", "a", "zz", "c", "c" ,"a", "a", "a", "zz", "c"]

b = ["z","y","x"]
y = V{String, R}(b)
append!(x, y)
@test length(x) == 15
@test x[end-2] == "z"
@test x[end-1] == "y"
@test x[end] == "x"
@test x == ["c", "a", "a", "a", "zz", "c", "c" ,"a", "a", "a", "zz", "c", "z", "y", "x"]
@test levels(x) == ["e", "a", "b", "c", "zz", "z", "y", "x"]

empty!(x)
Expand Down Expand Up @@ -295,26 +281,13 @@ for (A, V, M) in ((NominalArray, NominalVector, NominalMatrix),

append!(x, x)
@test length(x) == 12
@test x[1] == -1.0
@test x[2] == -1.0
@test x[3] == 1.0
@test x[4] == 1.5
@test x[5] == 2.0
@test x[6] == -1.0
@test x[7] == -1.0
@test x[8] == -1.0
@test x[9] == 1.0
@test x[10] == 1.5
@test x[11] == 2.0
@test x[12] == -1.0
@test x == [-1.0, -1.0, 1.0, 1.5, 2.0, -1.0, -1.0, -1.0, 1.0, 1.5, 2.0, -1.0]

b = [2.5, 3.0, -3.5]
y = V{Float64, R}(b)
append!(x, y)
@test length(x) == 15
@test x[end-2] == 2.5
@test x[end-1] == 3.0
@test x[end] == -3.5
@test x == [-1.0, -1.0, 1.0, 1.5, 2.0, -1.0, -1.0, -1.0, 1.0, 1.5, 2.0, -1.0, 2.5, 3.0, -3.5]
@test levels(x) == [0.0,0.5,1.0,1.5,-1.0,2.0,2.5,3.0,-3.5]

empty!(x)
Expand Down
42 changes: 13 additions & 29 deletions test/12_nullablearray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,38 +148,35 @@ for (A, V, M) in ((NullableNominalArray, NullableNominalVector, NullableNominalM

push!(x, "e")
@test length(x) == 4
@test get(x[end]) == "e"
@test isequal(x, NullableArray(["c", "", "", "e"], [false, true, true, false]))
@test levels(x) == ["e", "c"]

push!(x, "zz")
@test length(x) == 5
@test get(x[end]) == "zz"
@test isequal(x, NullableArray(["c", "", "", "e", "zz"], [false, true, true, false, false]))
@test levels(x) == ["e", "c", "zz"]

push!(x, x[1])
@test length(x) == 6
@test get(x[1]) == get(x[end])
@test isequal(x, NullableArray(["c", "", "", "e", "zz", "c"], [false, true, true, false, false, false]))
@test levels(x) == ["e", "c", "zz"]

push!(x, eltype(x)())
@test length(x) == 7
@test isequal(x, NullableArray(["c", "", "", "e", "zz", "c", ""], [false, true, true, false, false, false, true]))
@test isnull(x[end])
@test levels(x) == ["e", "c", "zz"]

y = V{String, R}(levels(x))
append!(x, y)
@test length(x) == 10
append!(x, x)
@test isequal(x, NullableArray(["c", "", "", "e", "zz", "c", "", "c", "", "", "e", "zz", "c", ""], [false, true, true, false, false, false, true, false, true, true, false, false, false, true]))
@test length(x) == 14

b = ["z","y","x"]
y = V{String, R}(b)
append!(x, y)
@test length(x) == 13
@test levels(x) == ["e", "c", "zz", "z", "y", "x"]

push!(y, eltype(y)())
append!(x, y)
@test isnull(x[end])
@test length(x) == 17
@test levels(x) == ["e", "c", "zz", "z", "y", "x"]
@test isequal(x, NullableArray(["c", "", "", "e", "zz", "c", "", "c", "", "", "e", "zz", "c", "", "z", "y", "x"], [false, true, true, false, false, false, true, false, true, true, false, false, false, true, false, false, false]))

empty!(x)
@test length(x) == 0
Expand Down Expand Up @@ -402,36 +399,23 @@ for (A, V, M) in ((NullableNominalArray, NullableNominalVector, NullableNominalM

push!(x, 2.0)
@test length(x) == 5
@test get(x[end]) == 2.0
@test isequal(x, NullableArray([-1.0, -1.0, 1.0, 1.5, 2.0]))
@test levels(x) == [0.0, 0.5, 1.0, 1.5, -1.0, 2.0]

push!(x, x[1])
@test length(x) == 6
@test x[1] == x[end]
@test isequal(x, NullableArray([-1.0, -1.0, 1.0, 1.5, 2.0, -1.0]))
@test levels(x) == [0.0, 0.5, 1.0, 1.5, -1.0, 2.0]

append!(x, x)
@test length(x) == 12
@test get(x[1]) == -1.0
@test get(x[2]) == -1.0
@test get(x[3]) == 1.0
@test get(x[4]) == 1.5
@test get(x[5]) == 2.0
@test get(x[6]) == -1.0
@test get(x[7]) == -1.0
@test get(x[8]) == -1.0
@test get(x[9]) == 1.0
@test get(x[10]) == 1.5
@test get(x[11]) == 2.0
@test get(x[12]) == -1.0
@test isequal(x, NullableArray([-1.0, -1.0, 1.0, 1.5, 2.0, -1.0, -1.0, -1.0, 1.0, 1.5, 2.0, -1.0]))

b = [2.5, 3.0, -3.5]
y = V{Float64, R}(b)
append!(x, y)
@test length(x) == 15
@test get(x[end-2]) == 2.5
@test get(x[end-1]) == 3.0
@test get(x[end]) == -3.5
@test isequal(x, NullableArray([-1.0, -1.0, 1.0, 1.5, 2.0, -1.0, -1.0, -1.0, 1.0, 1.5, 2.0, -1.0, 2.5, 3.0, -3.5]))
@test levels(x) == [0.0,0.5,1.0,1.5,-1.0,2.0,2.5,3.0,-3.5]

empty!(x)
Expand Down

0 comments on commit 7786cd3

Please sign in to comment.