From ef30220bde54b7e640b653555a2978ec5c23a160 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Thu, 10 Oct 2024 11:41:29 +0200 Subject: [PATCH] add tests --- tests/testthat/test-colour-manip.R | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/testthat/test-colour-manip.R b/tests/testthat/test-colour-manip.R index a2f93225..744abb7e 100644 --- a/tests/testthat/test-colour-manip.R +++ b/tests/testthat/test-colour-manip.R @@ -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")) + +})