Skip to content

Commit d2e7cd0

Browse files
committed
added tests for asDataFrame
1 parent cf3198d commit d2e7cd0

2 files changed

Lines changed: 55 additions & 1 deletion

File tree

R/ds.asDataFrame.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
#' }
5252
#' @author Tim Cadman
5353
#' @export
54-
#'
5554
ds.asDataFrame <- function(x.name=NULL, newobj=NULL, datasources=NULL){
5655

5756
# look for DS connections
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#-------------------------------------------------------------------------------
2+
# Copyright (c) 2018-2022 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.asDataFrame::smk::setup")
16+
17+
connect.studies.dataset.cnsim(list("GENDER"))
18+
19+
test_that("setup", {
20+
ds_expect_variables(c("D"))
21+
})
22+
23+
#
24+
# Tests
25+
#
26+
27+
context("ds.asDataFrame::smk::simple test")
28+
test_that("simple test", {
29+
ds.asDataMatrix("D$GENDER")
30+
ds.asDataFrame(x.name="asdatamatrix.newobj")
31+
res.class <- ds.class("asdataframe.newobj")
32+
print(res.class)
33+
expect_length(res.class, 3)
34+
expect_length(res.class$sim1, 1)
35+
expect_true("data.frame" %in% res.class$sim1)
36+
expect_length(res.class$sim2, 1)
37+
expect_true("data.frame" %in% res.class$sim2)
38+
expect_length(res.class$sim3, 1)
39+
expect_true("data.frame" %in% res.class$sim3)
40+
})
41+
42+
#
43+
# Done
44+
#
45+
46+
context("ds.asDataFrame::smk::shutdown")
47+
48+
test_that("shutdown", {
49+
ds_expect_variables(c("D", "asdatamatrix.newobj", "asdataframe.newobj"))
50+
})
51+
52+
disconnect.studies.dataset.cnsim()
53+
54+
context("ds.asDataFrame::smk::done")
55+

0 commit comments

Comments
 (0)