context("test-tarififnser.R")
# test_that("Tarifs par essence de la foret de Chaux (IFN)", {
# test <- gftools::TarifIFNSER(fichier = system.file("extdata/shapes/FOREST/forest_chaux.shp", package = "gftools"), enreg = F) %>%
# dplyr::mutate_all(as.character)
# df <- data.frame(
# c(
# "03", "11", "02", "09", "17C", "61", "14", "62", "24", "13G", "52", "12V", "54", "21C", "15S", "04", "22M", "20G", "20P", "64",
# "21O", "19", "23AB", "25B", "15P", "05"
# ),
# c(860, 558, 476, 450, 370, 292, 169, 146, 110, 100, 90, 78, 74, 60, 49, 47, 45, 41, 30, 22, 19, 18, 17, 17, 16, 14),
# c(
# "Chene sessile", "Charme", "Chene pedoncule", "Hetre", "Frene commun", "Sapin pectine", "Robinier faux acacia",
# "Epicea commun", "Tremble", "Aulne glutineux", "Pin sylvestre", "Bouleau verruqueux", "Pin noir d'autriche", "Erable champetre",
# "Erable sycomore", "Chene rouge", "Merisier", "Tilleul a grandes feuilles", "Tilleul a petites feuilles", "Douglas",
# "Erable a feuilles d'obier", "Peuplier cultive", "Alisier blanc", "Saule blanc", "Erable plane", "Chene pubescent"
# ),
# c(
# "SchR", "SchL", "SchR", "SchR", "SchL", "SchR", "SchL", "SchR", "SchL", "SchL", "SchL", "SchL", "SchL", "SchL", "SchL", "SchL",
# "SchL", "SchR", "SchL", "SchR", "SchR", "SchR", "SchR", "SchL", "SchL", "SchL"
# ),
# c(8, 5, 7.5, 9, 6.5, 11, 6.5, 11.5, 9, 6.5, 7.5, 6.5, 5, 4.5, 5.5, 8, 6, 10, 7, 10, 5.5, 12, 8.5, 2.5, 7.5, 1)
# ) %>%
# dplyr::mutate_all(as.character)
# colnames(df) <- colnames(test)
# rownames(test) <- NULL
# rownames(df) <- NULL
# expect_equal(test, df)
# })
test_that("Fichier null", {
expect_error(gftools::TarifIFNSER(fichier = NULL, enreg = F))
})
test_that("Fichier incorrect", {
expect_error(gftools::TarifIFNSER(fichier = "", enreg = F))
})
test_that("Enregistrement du tableau", {
skip_on_os("windows")
skip_on_appveyor()
skip_on_travis()
expect_message(
gftools::TarifIFNSER(fichier = system.file("extdata/shapes/FOREST/forest_chaux.shp", package = "gftools"), enreg = T),
"Result is saved in:"
)
# expect_equal(2*2, 4)
})
test_that("'distmax' trop petite", {
skip_on_os("windows")
skip_on_appveyor()
skip_on_travis()
shp <- sf::st_as_sfc("SRID=2154;POLYGON ((897977.022790107 6659116.00945953, 898064.16256213 6659114.35490689, 898061.956491952 6659016.18478398, 897974.816719929 6659018.39085416, 897977.022790107 6659116.00945953))")
sf::st_write(shp, "/tmp/shape.shp", delete_layer = TRUE, quiet = TRUE)
expect_error(gftools::TarifIFNSER(fichier = "/tmp/shape.shp", distmax = 500, enreg = F))
# expect_equal(2*2, 4)
})
# test_that("surf < 1e+06", {
# skip_on_os("windows")
# skip_on_appveyor()
# skip_on_travis()
# shp <- sf::st_as_sfc("SRID=2154;POLYGON ((897977.022790107 6659116.00945953, 898064.16256213 6659114.35490689, 898061.956491952 6659016.18478398, 897974.816719929 6659018.39085416, 897977.022790107 6659116.00945953))")
# sf::st_write(shp, "/tmp/shape.shp", delete_layer = TRUE, quiet = TRUE)
# test <- gftools::TarifIFNSER(fichier = "/tmp/shape.shp", distmax = 5000, enreg = F) %>%
# dplyr::mutate_all(as.character)
# df <- data.frame(
# c("03", "02", "17C", "09"),
# c(20, 17, 13, 12),
# c("Chene sessile", "Chene pedoncule", "Frene commun", "Hetre"),
# c("SchR", "SchL", "SchL", "SchL"),
# c(8.5, 6, 11, 8)
# ) %>%
# dplyr::mutate_all(as.character)
# colnames(df) <- colnames(test)
# rownames(test) <- NULL
# rownames(df) <- NULL
# expect_equal(test, df)
# })
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.