File: test-aes-setting.r

package info (click to toggle)
r-cran-ggplot2 1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 4,412 kB
  • sloc: sh: 9; makefile: 1
file content (23 lines) | stat: -rw-r--r-- 623 bytes parent folder | download
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))


})