# tests/testthat/test-eq5dlss.R In fragla/eq5d: Methods for Analysing 'EQ-5D' Data and Calculating 'EQ-5D' Index Scores

```context("EQ-5D LSS")

test_that("single lss gives correct answer", {
})

test_that("five digit lss gives correct answer", {
expect_equal(lss(12321, version="3L"), 9)
expect_equal(lss(55555, version="5L"), 25)
expect_equal(lss(12321, version="Y3L"), 9)
expect_equal(lfs(55575, version="5L", ignore.invalid=TRUE), NA)
expect_equal(lss(c(11111,12345, 55555), version="5L"), c(5,15,25))
expect_equal(lss(as.character(c(11111,12345, 55555)), version="5L"), c(5,15,25))
})

test.df.2 <- test.df
colnames(test.df.2) <- c("M", "S", "U", "P", "A")

test_that("data.frame lss gives correct answer", {
expect_equal(lss(test.df, version="5L"), c(5,17,14,15,13))
expect_equal(lss(test.df.2, version="5L", dimensions=c("M","S","U","P","A")), c(5,17,14,15,13))
})

test_that("matrix lss gives correct answer", {
expect_equal(lss(as.matrix(test.df), version="5L"), c(5,17,14,15,13))
})

test_that("five digit in data.fram lss gives correct answer", {
expect_equal(lss(data.frame(five.digit=c(11111,12345, 55555)), version="5L", five.digit="five.digit"), c(5,15,25))
})

test_that("lss throws error for incorrect parameters", {
expect_error(lss(12345, version="3L", ignore.invalid=FALSE))