1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
context("Aes - setting values")
test_that("Aesthetic parameters must match length of data", {
df <- data.frame(x = 1:5, y = 1:5)
p <- ggplot(df, aes(x, y))
set_colours <- function(colours) {
pdf(file=NULL)
print(p + geom_point(colour = colours))
dev.off()
}
set_colours("red")
expect_error(set_colours(rep("red", 2)), "Incompatible lengths")
dev.off() # Need to manually close device because of error
expect_error(set_colours(rep("red", 3)), "Incompatible lengths")
dev.off()
expect_error(set_colours(rep("red", 4)), "Incompatible lengths")
dev.off()
set_colours(rep("red", 5))
})
|