1context("coord_train") 2 3test_that("NA's don't appear in breaks", { 4 5 # Returns true if any major/minor breaks have an NA 6 any_NA_major_minor <- function(trained) { 7 ns <- names(trained)[grepl("(\\.major)|(\\.minor)$", names(trained))] 8 9 for (n in ns) { 10 if (!is.null(trained[n]) && any(is.na(trained[n]))) 11 return(TRUE) 12 } 13 14 return(FALSE) 15 } 16 17 scale_x <- scale_x_continuous(limits = c(1, 12)) 18 scale_y <- scale_y_continuous(limits = c(1, 12)) 19 20 # First have to test that scale_breaks_positions will return a vector with NA 21 # This is a test to make sure the later tests will be useful! 22 # It's possible that changes to the the way that breaks are calculated will 23 # make it so that scale_break_positions will no longer give NA for range 1, 12 24 expect_true(any(is.na(scale_x$break_positions()))) 25 expect_true(any(is.na(scale_y$break_positions()))) 26 27 # Check the various types of coords to make sure they don't have NA breaks 28 expect_false(any_NA_major_minor(coord_polar()$setup_panel_params(scale_x, scale_y))) 29 expect_false(any_NA_major_minor(coord_cartesian()$setup_panel_params(scale_x, scale_y))) 30 expect_false(any_NA_major_minor(coord_trans()$setup_panel_params(scale_x, scale_y))) 31 expect_false(any_NA_major_minor(coord_fixed()$setup_panel_params(scale_x, scale_y))) 32 33 skip_if_not_installed("mapproj") 34 expect_false(any_NA_major_minor(coord_map()$setup_panel_params(scale_x, scale_y))) 35}) 36