Skip to content

Commit 5860e48

Browse files
Add some new and missing tests
1 parent b47bfe7 commit 5860e48

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

tests/testthat/test-ccdr_singleR.R

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ test_that("Check input: betas", {
153153
test_that("Check input: lambda", {
154154

155155
### lambda is numeric
156-
### TODO
156+
expect_error(ccdr_singleR(cors = cors.test, pp = pp, nn = nn, betas = betas.test, sigmas = sigmas.test, lambda = "a", weights = weights.test, gamma = gamma.test, eps = eps.test, maxIters = maxIters.test, alpha = alpha.test),
157+
"lambda must be numeric")
157158

158159
### lambda is negative
159160
expect_error(ccdr_singleR(cors = cors.test, pp = pp, nn = nn, betas = betas.test, sigmas = sigmas.test, lambda = -lambda.test, weights = weights.test, gamma = gamma.test, eps = eps.test, maxIters = maxIters.test, alpha = alpha.test),
@@ -163,27 +164,32 @@ test_that("Check input: lambda", {
163164
test_that("Check input: weights", {
164165

165166
### weights is length pp*pp
166-
### TODO
167+
expect_error(ccdr_singleR(cors = cors.test, pp = pp, nn = nn, betas = betas.test, sigmas = sigmas.test, lambda = lambda.test, weights = c(1, weights.test), gamma = gamma.test, eps = eps.test, maxIters = maxIters.test, alpha = alpha.test),
168+
"weights must have length p")
167169

168170
### weights is numeric
169-
### TODO
171+
expect_error(ccdr_singleR(cors = cors.test, pp = pp, nn = nn, betas = betas.test, sigmas = sigmas.test, lambda = lambda.test, weights = rep("a", pp*pp), gamma = gamma.test, eps = eps.test, maxIters = maxIters.test, alpha = alpha.test),
172+
"weights must be numeric")
170173

171174
### weight > 1
172175
weights.test <- rep(1, pp*pp)
173176
weights.test[1] <- 2
174-
expect_error(ccdr_singleR(cors = cors.test, pp = pp, nn = nn, betas = betas.test, sigmas = sigmas.test, lambda = lambda.test, weights = weights.test, gamma = -5, eps = eps.test, maxIters = maxIters.test, alpha = alpha.test), "weights out of bounds")
177+
expect_error(ccdr_singleR(cors = cors.test, pp = pp, nn = nn, betas = betas.test, sigmas = sigmas.test, lambda = lambda.test, weights = weights.test, gamma = gamma.test, eps = eps.test, maxIters = maxIters.test, alpha = alpha.test),
178+
"weights out of bounds")
175179

176180
### weight < 1
177181
weights.test <- rep(1, pp*pp)
178182
weights.test[1] <- -2
179-
expect_error(ccdr_singleR(cors = cors.test, pp = pp, nn = nn, betas = betas.test, sigmas = sigmas.test, lambda = lambda.test, weights = weights.test, gamma = -1, eps = eps.test, maxIters = maxIters.test, alpha = alpha.test), "weights out of bounds")
183+
expect_error(ccdr_singleR(cors = cors.test, pp = pp, nn = nn, betas = betas.test, sigmas = sigmas.test, lambda = lambda.test, weights = weights.test, gamma = gamma.test, eps = eps.test, maxIters = maxIters.test, alpha = alpha.test),
184+
"weights out of bounds")
180185

181186
})
182187

183188
test_that("Check input: gamma", {
184189

185190
### gamma is numeric
186-
### TODO
191+
expect_error(ccdr_singleR(cors = cors.test, pp = pp, nn = nn, betas = betas.test, sigmas = sigmas.test, lambda = lambda.test, weights = weights.test, gamma = "a", eps = eps.test, maxIters = maxIters.test, alpha = alpha.test),
192+
"gamma must be numeric")
187193

188194
### gamma is negative
189195
expect_error(ccdr_singleR(cors = cors.test, pp = pp, nn = nn, betas = betas.test, sigmas = sigmas.test, lambda = lambda.test, weights = weights.test, gamma = -5, eps = eps.test, maxIters = maxIters.test, alpha = alpha.test),
@@ -198,7 +204,8 @@ test_that("Check input: gamma", {
198204
test_that("Check input: eps", {
199205

200206
### eos is numeric
201-
### TODO
207+
expect_error(ccdr_singleR(cors = cors.test, pp = pp, nn = nn, betas = betas.test, sigmas = sigmas.test, lambda = lambda.test, weights = weights.test, gamma = gamma.test, eps = "a", maxIters = maxIters.test, alpha = alpha.test),
208+
"eps must be numeric")
202209

203210
### eps is negative
204211
expect_error(ccdr_singleR(cors = cors.test, pp = pp, nn = nn, betas = betas.test, sigmas = sigmas.test, lambda = lambda.test, weights = weights.test, gamma = gamma.test, eps = -5, maxIters = maxIters.test, alpha = alpha.test),
@@ -212,7 +219,8 @@ test_that("Check input: eps", {
212219
test_that("Check input: maxIters", {
213220

214221
### maxIters is integer
215-
### TODO
222+
expect_error(ccdr_singleR(cors = cors.test, pp = pp, nn = nn, betas = betas.test, sigmas = sigmas.test, lambda = lambda.test, weights = weights.test, gamma = gamma.test, eps = eps.test, maxIters = 5, alpha = alpha.test),
223+
"maxIters must be an integer")
216224

217225
### maxIters is negative
218226
expect_error(ccdr_singleR(cors = cors.test, pp = pp, nn = nn, betas = betas.test, sigmas = sigmas.test, lambda = lambda.test, weights = weights.test, gamma = gamma.test, eps = eps.test, maxIters = -5L, alpha = alpha.test),

0 commit comments

Comments
 (0)