Skip to content

Commit 8a385d5

Browse files
committed
Additional argument checking
1 parent 2a7e2ca commit 8a385d5

4 files changed

Lines changed: 7 additions & 5 deletions

File tree

R/ds.kurtosis.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ ds.kurtosis <- function(x=NULL, method=1, type='both', datasources=NULL){
4444
if(type == 'combine' | type == 'combined' | type == 'combines' | type == 'c') type <- 'combine'
4545
if(type == 'split' | type == 'splits' | type == 's') type <- 'split'
4646
if(type == 'both' | type == 'b' ) type <- 'both'
47+
if(type != 'combine' & type != 'split' & type != 'both')
48+
stop('Function argument "type" has to be either "both", "combine" or "split"', call.=FALSE)
4749

4850
# the input variable might be given as column table (i.e. D$x)
4951
# or just as a vector not attached to a table (i.e. x)

R/ds.skewness.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ ds.skewness <- function(x=NULL, method=1, type='both', datasources=NULL){
4444
if(type == 'combine' | type == 'combined' | type == 'combines' | type == 'c') type <- 'combine'
4545
if(type == 'split' | type == 'splits' | type == 's') type <- 'split'
4646
if(type == 'both' | type == 'b' ) type <- 'both'
47-
47+
if(type != 'combine' & type != 'split' & type != 'both')
48+
stop('Function argument "type" has to be either "both", "combine" or "split"', call.=FALSE)
49+
4850
# the input variable might be given as column table (i.e. D$x)
4951
# or just as a vector not attached to a table (i.e. x)
5052
# we have to make sure the function deals with each case

tests/testthat/test-arg-ds.kurtosis.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ test_that("setup", {
2727
context("ds.kurtosis::arg::test errors")
2828
test_that("kurtosis_erros", {
2929
expect_error(ds.kurtosis(), "Please provide the name of the input vector!", fixed=TRUE)
30-
res <- ds.kurtosis(x='D$LAB_TSC', type='datashield')
31-
expect_true(is.null(res))
30+
expect_error(ds.kurtosis(x='D$LAB_TSC', type='datashield'), "Function argument \"type\" has to be either \"both\", \"combine\" or \"split\"", fixed=TRUE)
3231
expect_error(ds.kurtosis(x='D$LAB_TSC', method="0"), "method must be an integer between 1 and 3", fixed=TRUE)
3332
expect_error(ds.kurtosis(x='D$LAB_TSC', method="4"), "method must be an integer between 1 and 3", fixed=TRUE)
3433
})

tests/testthat/test-arg-ds.skewness.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ test_that("setup", {
2727
context("ds.skewness::arg::test errors")
2828
test_that("skewness_erros", {
2929
expect_error(ds.skewness(), "Please provide the name of the input vector!", fixed=TRUE)
30-
res <- ds.skewness(x='D$LAB_TSC', type='datashield')
31-
expect_true(is.null(res))
30+
expect_error(ds.skewness(x='D$LAB_TSC', type='datashield'), "Function argument \"type\" has to be either \"both\", \"combine\" or \"split\"", fixed=TRUE)
3231
expect_error(ds.skewness(x='D$LAB_TSC', method="0"), "method must be an integer between 1 and 3", fixed=TRUE)
3332
expect_error(ds.skewness(x='D$LAB_TSC', method="4"), "method must be an integer between 1 and 3", fixed=TRUE)
3433
})

0 commit comments

Comments
 (0)