stRoke/tests/testthat/test-contrast_text.R

12 lines
423 B
R
Raw Normal View History

2023-04-12 13:59:26 +02:00
# Unit test for contrast_text()
library(testthat)
test_that("contrast_text() returns the correct text color", {
expect_equal(contrast_text("#FFFFFF"), "black")
expect_equal(contrast_text("#000000"), "white")
2023-04-12 19:55:40 +02:00
expect_equal(contrast_text("#FFFFFF", light_text="blue", dark_text="green"),
"green")
expect_equal(contrast_text("#000000", light_text="blue", dark_text="green"),
"blue")
2023-04-12 13:59:26 +02:00
})