Skip to content

Commit 53acb30

Browse files
committed
Merge common parts of tests
1 parent 51e60a9 commit 53acb30

File tree

1 file changed

+21
-45
lines changed

1 file changed

+21
-45
lines changed

test/13_arraycommon.jl

Lines changed: 21 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -428,58 +428,34 @@ end
428428
end
429429

430430
@testset "fill!()" begin
431-
@testset "non-missing" begin
432-
x = categorical(["a", "b", "c"])
433-
x2 = copy(x)
434-
@test fill!(x2, "a") === x2
435-
@test x2 == ["a", "a", "a"]
436-
@test levels(x2) == ["a", "b", "c"]
431+
x = CategoricalArray{Union{String, T}}(["a", "b", "c"])
432+
x2 = copy(x)
433+
@test fill!(x2, "a") === x2
434+
@test x2 == ["a", "a", "a"]
435+
@test levels(x2) == ["a", "b", "c"]
437436

438-
@test fill!(x2, x[2]) == ["b", "b", "b"]
439-
@test levels(x2) == ["a", "b", "c"]
437+
@test fill!(x2, x[2]) == ["b", "b", "b"]
438+
@test levels(x2) == ["a", "b", "c"]
440439

441-
x2 = copy(x)
442-
@test_throws MethodError fill!(x2, missing)
443-
@test x2 == x
444-
@test_throws MethodError fill!(x2, 3)
445-
@test x2 == x
446-
447-
fill!(x2, :c)
448-
@test x2 == ["c", "c", "c"]
449-
@test levels(x2) == ["a", "b", "c"]
450-
451-
fill!(x2, "0")
452-
@test x2 == ["0", "0", "0"]
453-
@test levels(x2) == ["a", "b", "c", "0"]
454-
end
455-
456-
@testset "missing" begin
457-
x = categorical(Union{String, Missing}["a", "b", "c"])
458-
459-
x2 = copy(x)
460-
@test fill!(x2, "a") === x2
461-
@test x2 == ["a", "a", "a"]
462-
@test levels(x2) == ["a", "b", "c"]
463-
464-
@test fill!(x2, x[2]) == ["b", "b", "b"]
465-
@test levels(x2) == ["a", "b", "c"]
466-
467-
x2 = copy(x)
468-
fill!(x2, "0")
469-
@test x2 == ["0", "0", "0"]
470-
@test levels(x2) == ["a", "b", "c", "0"]
440+
x2 = copy(x)
441+
@test_throws MethodError fill!(x2, 3)
442+
@test x2 == x
471443

444+
if T === Missing
472445
x2 = fill!(copy(x), missing)
473446
@test all(ismissing, x2)
474-
475-
x2 = copy(x)
476-
@test_throws MethodError fill!(x2, 3.0)
447+
else
448+
@test_throws MethodError fill!(x2, missing)
477449
@test x2 == x
478-
479-
fill!(x2, Symbol(1))
480-
@test x2 == ["1", "1", "1"]
481-
@test levels(x2) == ["a", "b", "c", "1"]
482450
end
451+
452+
fill!(x2, :c)
453+
@test x2 == ["c", "c", "c"]
454+
@test levels(x2) == ["a", "b", "c"]
455+
456+
fill!(x2, "0")
457+
@test x2 == ["0", "0", "0"]
458+
@test levels(x2) == ["a", "b", "c", "0"]
483459
end
484460

485461
@testset "overflow of reftype is detected and doesn't corrupt data and levels" begin

0 commit comments

Comments
 (0)