Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
teunbrand committed Oct 10, 2024
1 parent 40f6adc commit ef30220
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/testthat/test-colour-manip.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,14 @@ test_that("col_saturate can (de)saturate colours", {
expect_equal(col_saturate(x, -30), c("#996666", "#669966", "#666699"))
})

test_that("colour manipulation functions work on palettes", {

pal <- pal_manual(c("#FF0000", "#00FF00", "#0000FF"))

expect_equal(col_shift(pal, 180)(3), c("#00B8B8", "#FF92FF", "#535300"))
expect_equal(col_darker(pal, 30)(3), c("#660000", "#006600", "#000066"))
expect_equal(col_lighter(pal, 30)(3), c("#FF9999", "#99FF99", "#9999FF"))
expect_equal(col_saturate(pal, -50)(3), c("#BF4040", "#40BF40", "#4040BF"))
expect_equal(col_mix(pal, "white")(3), c("#FF8080", "#80FF80", "#8080FF"))

})

0 comments on commit ef30220

Please sign in to comment.