# Generated by fusen: do not edit by hand
library(testthat)
library(dplyr)
test_that("calculate_distance works", {
expect_true(inherits(calculate_distance, "function"))
})
test_that("test conformite calculate_distance", {
data(dataset_obs)
data(dataset_segs)
test <- dataset_obs %>%
calculate_distance(transect_obj = dataset_segs,
crs = 2154) %>%
slice(1:5)
exp <- structure(list(distance_m = c(39.7781721821674, 1883.49604130592,
1775.49764373098, 861.960327775514, 1002.83798668127), Sample.Label = c("8-10",
"15-10", "15-4", "16-3", "17-10"), size = c(1, 1, 1, 1, 1), distance_km = c(0.0397781721821674,
1.88349604130592, 1.77549764373098, 0.861960327775514, 1.00283798668127
), x = c(-142269.524360142, -159212.578236191, -148643.452974568,
-168285.730494252, -169143.988133009), y = c(6260733.72869475,
6253182.64985506, 6247794.33171267, 6253187.6413422, 6251608.74650909
), object = 1:5), row.names = c(NA, -5L), class = "data.frame")
expect_equal(object = test,
expected = exp)
expect_is(test, "data.frame")
})
test_that("test erreur calculate_distance", {
data(iris)
data(dataset_obs)
data(dataset_segs)
expect_error(object = calculate_distance(obs_obj = iris,
transect_obj = dataset_segs,
crs = 2154))
expect_error(object = calculate_distance(obs_obj = dataset_obs,
transect_obj = iris,
crs = 2154))
expect_error(object = calculate_distance(obs_obj = "haha",
transect_obj = iris,
crs = 2154))
dataset_segs_test <- dataset_segs %>%
rename(nop = Sample.Label)
expect_error(object = calculate_distance(obs_obj = dataset_obs,
transect_obj = dataset_segs_test,
crs = 2154))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.