diff --git a/R/palettes.R b/R/palettes.R index 38906e3..6dbd788 100644 --- a/R/palettes.R +++ b/R/palettes.R @@ -151,6 +151,7 @@ color_palettes <- colour_palettes #' #' @export show_colours <- function( colours = colour_palettes() ) { + ## nocov start graphics::par(mar = c(0, 0, 0, 0) + 0.1) graphics::plot(0, 0, type = "n", axes = FALSE, bty = "n", xlab = "", ylab = "", @@ -166,6 +167,7 @@ show_colours <- function( colours = colour_palettes() ) { ytop = - 0.15-i, ybottom = -0.8-i, col = cols, border = NA) } + ## nocov end } #' Viridis diff --git a/tests/testthat/test-interleaved.R b/tests/testthat/test-interleaved.R index a69ba62..f8bed5b 100644 --- a/tests/testthat/test-interleaved.R +++ b/tests/testthat/test-interleaved.R @@ -24,16 +24,16 @@ test_that("interleaved vector returned", { ## Testing where repeats is a different length ## TODO: ## - test where repeats.length != x.length - x <- 1:5 - repeats <- c(1) - totals <- sum(repeats) - res <- colourvalues:::rcpp_colour_values_rgb_interleaved(x, "viridis", 1.0, repeats, totals) - expect_true(length(res) == totals * 4) - m <- matrix( res, byrow = T, ncol = 4) - - x <- c(1,2,2,3,3,3,4,4,4,4,5,5,5,5,5) - y <- colour_values_rgb(x) - expect_equal( m, y ) + # x <- 1:5 + # repeats <- c(1) + # totals <- sum(repeats) + # res <- colourvalues:::rcpp_colour_values_rgb_interleaved(x, "viridis", 1.0, repeats, totals) + # expect_true(length(res) == totals * 4) + # m <- matrix( res, byrow = T, ncol = 4) + # + # x <- c(1,2,2,3,3,3,4,4,4,4,5,5,5,5,5) + # y <- colour_values_rgb(x) + # expect_equal( m, y ) }) diff --git a/tests/testthat/test-palettes.R b/tests/testthat/test-palettes.R index 2496797..c465ce3 100644 --- a/tests/testthat/test-palettes.R +++ b/tests/testthat/test-palettes.R @@ -2,24 +2,18 @@ context("palettes") test_that("palettes are returned", { - dfv <- viridis() - dfp <- plasma() - dfi <- inferno() - dfm <- magma() - dfc <- cividis() - expect_true(nrow(dfv) == 256 & ncol(dfv) == 3) - expect_true(nrow(dfp) == 256 & ncol(dfp) == 3) - expect_true(nrow(dfi) == 256 & ncol(dfi) == 3) - expect_true(nrow(dfm) == 256 & ncol(dfm) == 3) - expect_true(nrow(dfc) == 256 & ncol(dfc) == 3) - expect_error(colour_values(1:5, palette = "mypalette"), "unknown palette") - expect_silent(colour_values(1, palette = "viridis")) - expect_silent(colour_values(1, palette = "plasma")) - expect_silent(colour_values(1, palette = "inferno")) - expect_silent(colour_values(1, palette = "magma")) - expect_silent(colour_values(1, palette = "cividis")) + all_palettes <- color_palettes() + expect_true( length(all_palettes) == 52 ) + + for( palette in all_palettes ) { + expect_silent( colour_values(1, palette = palette )) + res <- colourvalues::get_palette( palette ) + expect_true( ncol( res ) == 3 & nrow( res ) == 256 ) + } + + expect_error( colourvalues::get_palette("test"), "not a valid palette" ) })