| 1 |
spectrum <- unname(t(col2rgb(rainbow(10)))) |
| 2 |
reconvert <- function(data, space) { |
| 3 |
unname(round(convert_colour(convert_colour(data, 'rgb', space), space, 'rgb'))) |
| 4 |
} |
| 5 |
test_that("basic io works", { |
| 6 |
expect_error(convert_colour(spectrum, 'test', 'lab')) |
| 7 |
expect_error(convert_colour(spectrum, 'rgb', 'test')) |
| 8 |
expect_equal(nrow(spectrum), nrow(convert_colour(spectrum, 'rgb', 'lab'))) |
| 9 |
}) |
| 10 |
|
| 11 |
test_that("cmy works", { |
| 12 |
expect_equal(spectrum, reconvert(spectrum, 'cmy')) |
| 13 |
}) |
| 14 |
test_that("cmyk works", { |
| 15 |
expect_equal(spectrum, reconvert(spectrum, 'cmyk')) |
| 16 |
}) |
| 17 |
test_that("hsl works", { |
| 18 |
expect_equal(spectrum, reconvert(spectrum, 'hsl')) |
| 19 |
}) |
| 20 |
test_that("hsb works", { |
| 21 |
expect_equal(spectrum, reconvert(spectrum, 'hsb')) |
| 22 |
}) |
| 23 |
test_that("hsv works", { |
| 24 |
expect_equal(spectrum, reconvert(spectrum, 'hsv')) |
| 25 |
}) |
| 26 |
test_that("lab works", { |
| 27 |
expect_equal(spectrum, reconvert(spectrum, 'lab')) |
| 28 |
}) |
| 29 |
test_that("hunterlab works", { |
| 30 |
expect_equal(spectrum, reconvert(spectrum, 'hunterlab')) |
| 31 |
}) |
| 32 |
test_that("lch works", { |
| 33 |
expect_equal(spectrum, reconvert(spectrum, 'lch')) |
| 34 |
}) |
| 35 |
test_that("luv works", { |
| 36 |
expect_equal(spectrum, reconvert(spectrum, 'luv')) |
| 37 |
}) |
| 38 |
test_that("rgb works", { |
| 39 |
expect_equal(spectrum, reconvert(spectrum, 'rgb')) |
| 40 |
}) |
| 41 |
test_that("xyz works", { |
| 42 |
expect_equal(spectrum, reconvert(spectrum, 'xyz')) |
| 43 |
}) |
| 44 |
test_that("yxy works", { |
| 45 |
expect_equal(spectrum, reconvert(spectrum, 'yxy')) |
| 46 |
}) |