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

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

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

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

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

test_that("data.frame lfs gives correct answer", {
expect_equal(lfs(test.df, version="5L"), c("50000","02102","11120","01310","21011"))
expect_equal(lfs(test.df.2, version="5L", dimensions=c("M","S","U","P","A")), c("50000","02102","11120","01310","21011"))
})

test_that("matrix lfs gives correct answer", {
expect_equal(lfs(as.matrix(test.df), version="5L"), c("50000","02102","11120","01310","21011"))
})

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

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