/
test-smk-asDataMatrixDS.R
64 lines (53 loc) · 1.59 KB
/
test-smk-asDataMatrixDS.R
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
#-------------------------------------------------------------------------------
# Copyright (c) 2019-2020 University of Newcastle upon Tyne. All rights reserved.
#
# This program and the accompanying materials
# are made available under the terms of the GNU Public License v3.0.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
#
# Set up
#
context("asDataMatrixDS::smk::setup")
#
# Tests
#
context("asDataMatrixDS::smk::simple")
test_that("simple asDataMatrixDS", {
input <- data.frame(v1 = c(0.0, 1.0, 2.0, 3.0, 4.0), v2 = c(4.0, 3.0, 2.0, 1.0, 0.0))
res <- asDataMatrixDS("input")
res.class <- class(res)
if (base::getRversion() < 4.0)
{
expect_length(res.class, 1)
expect_true("matrix" %in% res.class)
}
else
{
expect_length(res.class, 2)
expect_true("matrix" %in% res.class)
expect_true("array" %in% res.class)
}
expect_length(res, 10)
expect_equal(res[1], 0)
expect_equal(res[2], 1)
expect_equal(res[3], 2)
expect_equal(res[4], 3)
expect_equal(res[5], 4)
expect_equal(res[6], 4)
expect_equal(res[7], 3)
expect_equal(res[8], 2)
expect_equal(res[9], 1)
expect_equal(res[10], 0)
res.colnames <- colnames(res)
expect_length(res.colnames, 2)
expect_equal(res.colnames[1], "v1")
expect_equal(res.colnames[2], "v2")
})
#
# Done
#
context("asDataMatrixDS::smk::shutdown")
context("asDataMatrixDS::smk::done")