Skip to content

Commit

Permalink
Tests added for functions where deprecated "version = 'Y'" used.
Browse files Browse the repository at this point in the history
  • Loading branch information
fragla committed Feb 3, 2025
1 parent 32a49dd commit 8cbd90e
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 2 deletions.
10 changes: 10 additions & 0 deletions tests/testthat/test-eq5d.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,13 @@ test_that("when ignore.invalid flag is FALSE the correct answer is returned", {
expect_error(eq5d(c(MO=1,SC=2,UA=3,PD=2,AD=1), version="3L", type="ABC", country="Germany"))
expect_error(eq5d(0.923, country="UK", version="5L", type="DSU", age=50, sex="male", bwidth=0))
})

test_that("eq5d using version='Y' is deprecated", {
rlang::local_options(lifecycle_verbosity = "error")
expect_error(eq5d(33333, country="Slovenia", version="Y"))
})

test_that("eq5d using version='Y' still works", {
rlang::local_options(lifecycle_verbosity = "quiet")
expect_equal(eq5d(33333, country="Slovenia", version="Y"), -0.691)
})
10 changes: 10 additions & 0 deletions tests/testthat/test-eq5dcf.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,13 @@ dat.mat <- as.matrix(dat.df)
test_that("eq5dcf data.frame gives correct answer", {
expect_equal(eq5dcf(dat.mat, version="3L", ignore.invalid=TRUE), res)
})

test_that("eq5dcf using version='Y' is deprecated", {
rlang::local_options(lifecycle_verbosity = "error")
expect_error(eq5dcf(dat, version="Y", ignore.invalid=TRUE))
})

test_that("eq5dcf using version='Y' still works", {
rlang::local_options(lifecycle_verbosity = "quiet")
expect_equal(eq5dcf(dat, version="Y", ignore.invalid=TRUE), res)
})
10 changes: 10 additions & 0 deletions tests/testthat/test-eq5dds.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,13 @@ test_that("eq5dds throws error", {
expect_error(eq5dds(test1.df, version="7L"))
expect_error(eq5dds(test1.df[c("MO","SC","UA","PD")], version="3L"))
})

test_that("eq5dds using version='Y' is deprecated", {
rlang::local_options(lifecycle_verbosity = "error")
expect_error(eq5dds(test1.df, version="Y"))
})

test_that("eq5dds using version='Y' still works", {
rlang::local_options(lifecycle_verbosity = "quiet")
expect_equal(eq5dds(test1.df, version="Y"), res1.df)
})
10 changes: 10 additions & 0 deletions tests/testthat/test-eq5dlfs.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,13 @@ test_that("lfs throws error for incorrect parameters", {
expect_error(lss(data.frame(five.digit=c(11111,12345, 55555)), version="5L", dimensions=c("M","S","U","P","A")))

})

test_that("eq5dlfs using version='Y' is deprecated", {
rlang::local_options(lifecycle_verbosity = "error")
expect_error(lfs(c(MO=1,SC=2,UA=3,PD=2,AD=1), version="Y"))
})

test_that("eq5dlfs using version='Y' still works", {
rlang::local_options(lifecycle_verbosity = "quiet")
expect_equal(lfs(c(MO=1,SC=2,UA=3,PD=2,AD=1), version="Y"), "221")
})
10 changes: 10 additions & 0 deletions tests/testthat/test-eq5dlss.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,13 @@ test_that("lss returns NA for incorrect parameters when ignore.invalid=TRUE", {
expect_equal(lss(12345, version="3L", ignore.invalid=TRUE),NA)
expect_equal(lss(c(MO=1,SC=7,UA=3,PD=2,AD=1), version="3L", ignore.invalid=TRUE), NA)
})

test_that("eq5dlss using version='Y' is deprecated", {
rlang::local_options(lifecycle_verbosity = "error")
expect_error(lss(c(MO=1,SC=2,UA=3,PD=2,AD=1), version="Y"))
})

test_that("eq5dlss using version='Y' still works", {
rlang::local_options(lifecycle_verbosity = "quiet")
expect_equal(lss(c(MO=1,SC=2,UA=3,PD=2,AD=1), version="Y"), 9)
})
12 changes: 11 additions & 1 deletion tests/testthat/test-eq5dy3l.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,14 @@ test_that("EQ-5D-Y throws error for incorrect parameters", {
expect_error(eq5dy3l(c(MO=1,SC=2,UA=5,PD=2,AD=1), "Slovenia"))
expect_error(eq5dy3l(c(M0=1,SC=2,UA=5,PD=2,AD=1), "Slovenia"))
expect_error(eq5dy3l(c(MO=1,SC=2,UA=3,PD=2,AD=1), "Liechtenstein"))
})
})

test_that("eq5dlss using version='Y' is deprecated", {
rlang::local_options(lifecycle_verbosity = "error")
expect_error(eq5dy(c(MO=2,SC=2,UA=2,PD=2,AD=2), "Spain"))
})

test_that("eq5dlss using version='Y' still works", {
rlang::local_options(lifecycle_verbosity = "quiet")
expect_equal(eq5dy(c(MO=2,SC=2,UA=2,PD=2,AD=2), "Spain"), 0.458)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-eqhpg.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ test_that("eqhpg data.frame throws error", {
expect_error(hpg(pre.df[-1,], post.df, country = "UK", version="3L", type="TTO", ignore.invalid=TRUE))
expect_error(hpg(pre, post, country = "UK", type="TTO", no.problems = F))
})

test_that("eq5dhpg using version='Y' is deprecated", {
rlang::local_options(lifecycle_verbosity = "error")
expect_error(hpg(pre, post, country = "Brazil", version="Y", type="CW", no.problems = F))
})
12 changes: 11 additions & 1 deletion tests/testthat/test-eqhsdi.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,14 @@ test_that("eqhsdi five digit gives correct answer", {
test_that("eqhsdi throws error", {
expect_error(hsdi(pre, version="3L", ignore.invalid=FALSE))
expect_error(hsdi(pre))
})
})

test_that("eqhsdi using version='Y' is deprecated", {
rlang::local_options(lifecycle_verbosity = "error")
expect_error(hsdi(pre, version="Y"))
})

test_that("eq5dhsdi using version='Y' still works", {
rlang::local_options(lifecycle_verbosity = "quiet")
expect_equal(hsdi(pre, version="Y"), 0.56)
})
9 changes: 9 additions & 0 deletions tests/testthat/test-eqpchc.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,12 @@ test_that("eqpchc data.frame throws error", {
expect_error(pchc(pre.df[-1,], post.df, version="3L", ignore.invalid=FALSE))
})

test_that("eqpchc using version='Y' is deprecated", {
rlang::local_options(lifecycle_verbosity = "error")
expect_error(pchc(pre.df, post.df, version="Y", no.problems=TRUE, totals=TRUE))
})

test_that("eq5dpchc using version='Y' still works", {
rlang::local_options(lifecycle_verbosity = "quiet")
expect_equal(pchc(pre.df, post.df, version="Y", no.problems=TRUE, totals=TRUE), res1)
})
10 changes: 10 additions & 0 deletions tests/testthat/test-eqshannon.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,13 @@ test_that("eqshannon data.frame throws error", {
expect_error(shannon(pre.df, version="3L", permutations=TRUE, dimensions=c("M0","SC","UA","PD","AD")))
expect_error(shannon(pre.df, version="3L", permutations=TRUE, ignore.invalid=FALSE))
})

test_that("eqshannon using version='Y' is deprecated", {
rlang::local_options(lifecycle_verbosity = "error")
expect_error(shannon(pre, version="Y", by.dimension=TRUE, permutations=TRUE)$MO)
})

test_that("eq5dshannon using version='Y' still works", {
rlang::local_options(lifecycle_verbosity = "quiet")
expect_equal(shannon(pre, version="Y", by.dimension=TRUE, permutations=TRUE)$MO, list(H=0.97, H.max=1.58, J=0.61))
})
9 changes: 9 additions & 0 deletions tests/testthat/test-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,12 @@ test_that("get_health_states_from_dimensions throws an error", {
expect_error(get_health_states_from_dimensions(scores.df, version="5L", ignore.invalid=TRUE, dimensions=c("Mob","SC","UA","PD","AD")))
})

test_that("get_all_health_states using version='Y' is deprecated", {
rlang::local_options(lifecycle_verbosity = "error")
expect_error(get_all_health_states("Y")[c(4,41,106,158,179)])
})

test_that("get_all_health_states using version='Y' still works", {
rlang::local_options(lifecycle_verbosity = "quiet")
expect_equal(get_all_health_states("Y")[c(4,41,106,158,179)], c("11121","12222","21331","23322","31232"))
})

0 comments on commit 8cbd90e

Please sign in to comment.