> # test.describe.col.R
> 
> source("test.prolog.R")
Loading required package: rpart
> 
> show.prp.palettes() # initialize plot device so we can use palette function
> 
> describe.col <- function(col, show.hex=TRUE, check.palette.index=TRUE)
+ {
+     rpart.plot:::describe.col(col, show.hex, check.palette.index)
+ }
> stopifnot(identical(describe.col(1), "#000000 (black)"))
> stopifnot(identical(describe.col(2), "#FF0000 (red)"))
> 
> stopifnot(identical(describe.col(rgb(0, 1, 0)),  "#00FF00 (green)"))
> stopifnot(identical(describe.col(rgb(0, 1, 1)),  "#00FFFF (cyan)"))
> stopifnot(identical(describe.col(rgb(.1,.2,.3)), "#1A334D (near darkslategray #2F4F4F)"))
> 
> stopifnot(identical(describe.col(col2rgb(3)),         "#00CD00 (green3)"))
> stopifnot(identical(describe.col(col2rgb("green3")),  "#00CD00 (green3)"))
> stopifnot(identical(describe.col(col2rgb("#00CD01")), "#00CD01 (near green3 #00CD00)"))
> 
> stopifnot(identical(describe.col("salmon2"), "#EE8262 (salmon2)"))
> stopifnot(identical(describe.col("#EE8262"), "#EE8262 (salmon2)"))
> stopifnot(identical(describe.col("#EE8260"), "#EE8260 (near salmon2 #EE8262)"))
> stopifnot(identical(describe.col("#EE9260"), "#EE9260 (near salmon2 #EE8262)"))
> 
> stopifnot(identical(describe.col(0),             "#FFFFFF (white)"))
> stopifnot(identical(describe.col(0.0),           "#FFFFFF (white)"))
> stopifnot(identical(describe.col(0L),            "#FFFFFF (white)"))
> stopifnot(identical(describe.col(NA),            "#FFFFFF (white)"))
> stopifnot(identical(describe.col(col2rgb(NA)),   "#FFFFFF (white)"))
> stopifnot(identical(describe.col(col2rgb("NA")), "#FFFFFF (white)"))
> # col2rgb returns a matrix with 3 rows
> stopifnot(identical(describe.col(matrix(c(1,2,3), nrow=3)), "#010203 (near gray1 #030303)"))
> 
> expect.err(try(describe.col(1.23)),             "non-integer col is illegal")
Error : non-integer col is illegal
Got error as expected from try(describe.col(1.23))
> expect.err(try(describe.col(c(1,2))),           "only one color is allowed")
Error : only one color is allowed
Got error as expected from try(describe.col(c(1, 2)))
> expect.err(try(describe.col(c("red", "pink"))), "only one color is allowed")
Error : only one color is allowed
Got error as expected from try(describe.col(c("red", "pink")))
> expect.err(try(describe.col(-1)),               "col -1 is illegal (col must be greater than or equal to 0)")
Error : col -1 is illegal (col must be greater than or equal to 0)
Got error as expected from try(describe.col(-1))
> expect.err(try(describe.col(9)),                "illegal col 9 (only 8 colors in the current palette)")
Error : illegal col 9 (only 8 colors in the current palette)
Got error as expected from try(describe.col(9))
> expect.err(try(describe.col("nonesuch")),       "invalid color name 'nonesuch'")
Error in col2rgb(col) : invalid color name 'nonesuch'
Got error as expected from try(describe.col("nonesuch"))
> expect.err(try(describe.col(FALSE)),            "invalid color name 'FALSE'")
Error in col2rgb(col) : invalid color name 'FALSE'
Got error as expected from try(describe.col(FALSE))
> expect.err(try(describe.col(col2rgb(FALSE))),   "invalid color name 'FALSE'")
Error in col2rgb(FALSE) : invalid color name 'FALSE'
Got error as expected from try(describe.col(col2rgb(FALSE)))
> 
> par(old.par)
> 
> source("test.epilog.R")
