Skip to content

Commit 71c1ad1

Browse files
committed
added unit tests for include/exclude column feature
1 parent 53e0466 commit 71c1ad1

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

test/runtests.jl

+25-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ using Base.Test
1919
end
2020
end
2121

22-
@testset "manual" begin
22+
@testset "incremental read" begin
2323
fname = "test1.sas7bdat" # 10 rows
2424
handler = SASLib.open(fname)
2525
@test handler.config.filename == fname
@@ -31,7 +31,7 @@ using Base.Test
3131
@test result[:nrows] == 3
3232
end
3333

34-
@testset "numeric" begin
34+
@testset "various data types" begin
3535
result = readsas("test1.sas7bdat")
3636
df = result[:data]
3737
@test sum(df[:Column1][1:5]) == 2.066
@@ -40,7 +40,7 @@ using Base.Test
4040
@test df[:Column4][1:3] == [Date("1965-12-10"), Date("1977-03-07"), Date("1983-08-15")]
4141
end
4242

43-
@testset "datetime" begin
43+
@testset "datetime with missing values" begin
4444
result = readsas("datetime.sas7bdat")
4545
df = result[:data]
4646
@test (result[:nrows], result[:ncols]) == (5, 4)
@@ -50,6 +50,28 @@ using Base.Test
5050
@test count(ismissing, result[:data][:dt]) == 3
5151
end
5252

53+
@testset "include/exclude columns" begin
54+
result = readsas("productsales.sas7bdat", include_columns=[:MONTH, :YEAR])
55+
@test result[:ncols] == 2
56+
@test sort(result[:column_symbols]) == sort([:MONTH, :YEAR])
57+
58+
result = readsas("productsales.sas7bdat", include_columns=[1, 2, 7])
59+
@test result[:ncols] == 3
60+
@test sort(result[:column_symbols]) == sort([:ACTUAL, :PREDICT, :PRODUCT])
61+
62+
result = readsas("productsales.sas7bdat", exclude_columns=[:DIVISION])
63+
@test result[:ncols] == 9
64+
@test !(:DIVISION in result[:column_symbols])
65+
66+
result = readsas("productsales.sas7bdat", exclude_columns=collect(2:10))
67+
@test result[:ncols] == 1
68+
@test sort(result[:column_symbols]) == sort([:ACTUAL])
69+
70+
# error handling
71+
@test_throws SASLib.ConfigError readsas("productsales.sas7bdat",
72+
include_columns=[1], exclude_columns=[1])
73+
end
74+
5375
@testset "misc" begin
5476
result = readsas("productsales.sas7bdat")
5577
df = result[:data]

0 commit comments

Comments
 (0)