@@ -11,12 +11,9 @@ set.standard.disclosure.settings()
1111# Tests
1212#
1313
14- test_that(" simple matrixDetDS1" , {
15- M1 <- matrix (c(1 , 2 , 3 , 4 ), 2 , 2 )
16-
14+ test_that(" simple matrixDetDS1 passes with matrix of sufficient dimensions" , {
15+ M1 <- matrix (c(1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 10 ), 3 , 3 )
1716 res <- matrixDetDS1(" M1" , logarithm = FALSE )
18-
19- expect_true(is.list(res ))
2017 expect_equal(res $ matrix.determinant , determinant(M1 , logarithm = FALSE ))
2118})
2219
@@ -28,3 +25,18 @@ test_that("matrixDetDS1 errors when input is wrong type", {
2825 bad_input <- c(" a" , " b" , " c" )
2926 expect_error(matrixDetDS1(" bad_input" , logarithm = FALSE ), regexp = " must be of type" )
3027})
28+
29+ test_that(" matrixDetDS1 errors when matrix is too small (disclosure guard)" , {
30+ M1x1 <- matrix (7 , 1 , 1 )
31+ M2x2 <- matrix (c(1 , 2 , 3 , 4 ), 2 , 2 )
32+
33+ expect_error(matrixDetDS1(" M1x1" , logarithm = FALSE ), regexp = " too small" )
34+ expect_error(matrixDetDS1(" M2x2" , logarithm = FALSE ), regexp = " too small" )
35+ })
36+
37+ test_that(" matrixDetDS1 is blocked in non-permissive mode" , {
38+ options(datashield.privacyControlLevel = " non-permissive" )
39+ on.exit(options(datashield.privacyControlLevel = NULL ), add = TRUE )
40+ M1 <- matrix (c(1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 10 ), 3 , 3 )
41+ expect_error(matrixDetDS1(" M1" , logarithm = FALSE ), regexp = " non-permissive" )
42+ })
0 commit comments