-
Notifications
You must be signed in to change notification settings - Fork 1
/
runtests.jl
105 lines (81 loc) · 2.41 KB
/
runtests.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using Helium, DelimitedFiles
# Create testing matrix
testmat = [1.5 8 12 24;
7 22 24 75]
# File name in .he format
fileName = string(@__DIR__,"/data/testFile.he")
########################
# Test Writing/Reading #
########################
# Write the matrix in .he format
Helium.writehe(fileName, testmat)
# Read the .he file and compare with original matrix
newmat = Helium.readhe(fileName)
if newmat == testmat
println("IO Success!")
else
println("IO Something went wrong!")
end
#############################
# Test Converting CSV to He #
#############################
# TEST 1
# Test function to convert CSV to He, without header nor row names
# Create CSV file
csvFileName = string(fileName[1:end-2], "csv")
open(csvFileName, "w") do io
writedlm(io, testmat, ',')
end;
# Convert CSV to He
Helium.csv2he(csvFileName, Float64, isHeader = false)
# Read the .he file and compare with original matrix
newmat = Helium.readhe(fileName)
if newmat == testmat
println("Test 1: Converting is a success!")
else
println("Test 1: Something went wrong during conversion!")
end
# TEST 2
# Test function to convert CSV to He, with header but no row names
# Create testing matrix
testmat = [
"col1" "col2" "col3" "col4"
1.5 8 12 24
7 22 24 75
]
# Create CSV file
csvFileName = string(fileName[1:end-2], "csv")
open(csvFileName, "w") do io
writedlm(io, testmat, ',')
end;
# Convert CSV to He
Helium.csv2he(csvFileName, Float64)
# Read the .he file and compare with original matrix
newmat = Helium.readhe(fileName)
if newmat == testmat[2:end, :]
println("Test 2: Converting is a success!")
else
println("Test 2: Something went wrong during conversion!")
end
# TEST 3
# Test function to convert CSV to He, with header and row names
# Create testing matrix
testmat = [
"ID" "col1" "col2" "col3" "col4"
1 1.5 8 12 24
2 7 22 24 75
]
# Create CSV file
csvFileName = string(fileName[1:end-2], "csv")
open(csvFileName, "w") do io
writedlm(io, testmat, ',')
end;
# Convert CSV to He
Helium.csv2he(csvFileName, Float64, isRowNames = true)
# Read the .he file and compare with original matrix
newmat = Helium.readhe(fileName)
if newmat == testmat[2:end, 2:end]
println("Test 3: Converting is a success!")
else
println("Test 3: Something went wrong during conversion!")
end