Skip to content

Commit 1251513

Browse files
Merge pull request #256 from StuartWheater/v6.1-dev
Initial smoke tests for 'ds.abs' and 'ds.sqrt'
2 parents 9d9899f + 2fdaffc commit 1251513

2 files changed

Lines changed: 122 additions & 0 deletions

File tree

tests/testthat/test-smk-ds.abs.R

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#-------------------------------------------------------------------------------
2+
# Copyright (c) 2019-2020 University of Newcastle upon Tyne. All rights reserved.
3+
#
4+
# This program and the accompanying materials
5+
# are made available under the terms of the GNU Public License v3.0.
6+
#
7+
# You should have received a copy of the GNU General Public License
8+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
9+
#-------------------------------------------------------------------------------
10+
11+
#
12+
# Set up
13+
#
14+
15+
context("ds.abs::smk::setup")
16+
17+
connect.studies.dataset.cnsim(list("LAB_TSC"))
18+
19+
test_that("setup", {
20+
ds_expect_variables(c("D"))
21+
})
22+
23+
#
24+
# Tests
25+
#
26+
27+
context("ds.abs::smk")
28+
test_that("simple c", {
29+
res <- ds.abs("D$LAB_TSC", newobj = "abs.newobj")
30+
31+
expect_true(is.null(res))
32+
33+
res.length <- ds.length("abs.newobj")
34+
35+
expect_length(res.length, 4)
36+
expect_equal(res.length$`length of abs.newobj in sim1`, 2163)
37+
expect_equal(res.length$`length of abs.newobj in sim2`, 3088)
38+
expect_equal(res.length$`length of abs.newobj in sim3`, 4128)
39+
expect_equal(res.length$`total length of abs.newobj in all studies combined`, 9379)
40+
41+
res.class <- ds.class("abs.newobj")
42+
43+
expect_length(res.class, 3)
44+
expect_equal(res.class$sim1, "numeric")
45+
expect_equal(res.class$sim2, "numeric")
46+
expect_equal(res.class$sim3, "numeric")
47+
})
48+
49+
#
50+
# Done
51+
#
52+
53+
context("ds.abs::smk::shutdown")
54+
55+
test_that("setup", {
56+
ds_expect_variables(c("D", "abs.newobj"))
57+
})
58+
59+
disconnect.studies.dataset.cnsim()
60+
61+
context("ds.abs::smk::done")

tests/testthat/test-smk-ds.sqrt.R

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#-------------------------------------------------------------------------------
2+
# Copyright (c) 2019-2020 University of Newcastle upon Tyne. All rights reserved.
3+
#
4+
# This program and the accompanying materials
5+
# are made available under the terms of the GNU Public License v3.0.
6+
#
7+
# You should have received a copy of the GNU General Public License
8+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
9+
#-------------------------------------------------------------------------------
10+
11+
#
12+
# Set up
13+
#
14+
15+
context("ds.sqrt::smk::setup")
16+
17+
connect.studies.dataset.cnsim(list("LAB_TSC"))
18+
19+
test_that("setup", {
20+
ds_expect_variables(c("D"))
21+
})
22+
23+
#
24+
# Tests
25+
#
26+
27+
context("ds.sqrt::smk")
28+
test_that("simple c", {
29+
res <- ds.sqrt("D$LAB_TSC", newobj = "sqrt.newobj")
30+
31+
expect_true(is.null(res))
32+
33+
res.length <- ds.length("sqrt.newobj")
34+
35+
expect_length(res.length, 4)
36+
expect_equal(res.length$`length of sqrt.newobj in sim1`, 2163)
37+
expect_equal(res.length$`length of sqrt.newobj in sim2`, 3088)
38+
expect_equal(res.length$`length of sqrt.newobj in sim3`, 4128)
39+
expect_equal(res.length$`total length of sqrt.newobj in all studies combined`, 9379)
40+
41+
res.class <- ds.class("sqrt.newobj")
42+
43+
expect_length(res.class, 3)
44+
expect_equal(res.class$sim1, "numeric")
45+
expect_equal(res.class$sim2, "numeric")
46+
expect_equal(res.class$sim3, "numeric")
47+
})
48+
49+
#
50+
# Done
51+
#
52+
53+
context("ds.sqrt::smk::shutdown")
54+
55+
test_that("setup", {
56+
ds_expect_variables(c("D", "sqrt.newobj"))
57+
})
58+
59+
disconnect.studies.dataset.cnsim()
60+
61+
context("ds.sqrt::smk::done")

0 commit comments

Comments
 (0)