Skip to content

Commit 3f5a2c3

Browse files
committed
add tests
1 parent 3acdc97 commit 3f5a2c3

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

tests/testthat/test-datplot_utility.R

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,23 @@ test_that("check.structure issues warning", {
7373
expect_warning(check.structure(testdf), regexp = "recommended")
7474
})
7575

76+
77+
testdf <- create.testing.df()
78+
testdf[,3] <- sample(-200:0, nrow(testdf))
79+
testdf[,4] <- sample(1:200, nrow(testdf))
80+
testdf[1,3:4] <- c(4,4)
81+
82+
DAT_mat <- matrix(ncol = 5, nrow = nrow(testdf))
83+
DAT_mat[,1] <- 1:nrow(testdf)
84+
DAT_mat[,2] <- testdf[,3]
85+
DAT_mat[,3] <- testdf[,4]
86+
colnames(DAT_mat) <- c("index", "datmin", "datmax", "weight", "step")
87+
88+
test_that("create.sub.objects issues no warning", {
89+
expect_failure(expect_warning(create.sub.objects(DAT_mat, stepsize = 1),
90+
regexp = "stepsize is larger"))
91+
expect_warning(create.sub.objects(DAT_mat, stepsize = 5),
92+
regexp = "stepsize is larger")
93+
})
94+
95+

tests/testthat/test-datsteps.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,13 @@ test_that("error for wrong value of stepsize", {
1414
expect_warning(datsteps(DAT_df), regexp = "wrong order")
1515

1616
})
17+
18+
testdf <- create.testing.df()
19+
testdf[,3] <- sample(-200:0, nrow(testdf))
20+
testdf[,4] <- sample(1:200, nrow(testdf))
21+
testdf[1,3:4] <- c(4,4)
22+
23+
test_that("error for wrong value of stepsize", {
24+
expect_warning(datsteps(testdf), regexp = "the same value")
25+
expect_failure(expect_warning(datsteps(testdf, stepsize = 1), regexp = "larger than the range of the closest"))
26+
})

0 commit comments

Comments
 (0)