/
test-arg-ds.table.R
61 lines (45 loc) · 2.12 KB
/
test-arg-ds.table.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
#-------------------------------------------------------------------------------
# Copyright (c) 2018-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
#
connect.studies.dataset.cnsim(list("LAB_TSC"))
#
# Tests
#
context("ds.table::arg::test rvar has value")
test_that("table rvar has value", {
res <- ds.table()
expect_equal(res, "Error: rvar must have a value which is a character string naming the row variable for the table", fixed=TRUE)
})
context("ds.table::arg::test cvar has value")
test_that("table cvar has value", {
res <- ds.table(rvar="D$LAB_TSC", cvar=30)
expect_equal(res, "Error: if cvar is not null, it must have a value which is a character string naming the column variable for the table", fixed=TRUE)
})
context("ds.table::arg::test stvar has value")
test_that("table stvar has value", {
res <- ds.table(rvar="D$LAB_TSC", cvar=NULL, stvar=25)
expect_equal(res, "Error: if stvar is not null, it must have a value which is a character string naming the variable coding separate tables for the table", fixed=TRUE)
})
context("ds.table::arg::test stvar has CORRECT value")
test_that("table useNA has value", {
res <- ds.table(rvar="D$LAB_TSC", cvar=NULL, stvar=NULL, useNA = c("BEN"))
expect_equal(res, "Error: useNA must take one of the three values: 'no', 'ifany', or 'always'. Default is 'ifany'", fixed=TRUE)
})
context("ds.table::arg::test force.nfilter has value")
test_that("table force.nfilter has value", {
res <- ds.table(rvar="D$LAB_TSC", cvar=NULL, stvar=NULL, useNA = c("ifany"), force.nfilter =30)
expect_equal(res, "Error: if force.nfilter is not null, it must have a value which is a character string specifying an integer for the forced value of the nfilter", fixed=TRUE)
})
#
# Done
#
disconnect.studies.dataset.cnsim()