diff --git a/tests/testthat/test-jnd2xyz.R b/tests/testthat/test-jnd2xyz.R index 3498d6ff..d47de3bc 100644 --- a/tests/testthat/test-jnd2xyz.R +++ b/tests/testthat/test-jnd2xyz.R @@ -7,6 +7,13 @@ test_that("JND space for dichromat", { jnd_x <- jnd2xyz(cd.flowers, rotate = FALSE) + # After conversion to coordinates, the distance should not be modified + expect_equal( + as.matrix(dist(jnd_x, diag = TRUE, upper = TRUE)), + coldist2mat(cd.flowers)[["dS"]], + tolerance = 1e-6 + ) + jnd_x_rot <- jnd2xyz(cd.flowers, rotate = TRUE) expect_snapshot(jnd_x_rot) @@ -27,6 +34,12 @@ test_that("JND space for trichromat", { jnd_xy <- jnd2xyz(cd.flowers, rotate = FALSE) + # After conversion to coordinates, the distance should not be modified + expect_equal( + as.matrix(dist(jnd_xy, diag = TRUE, upper = TRUE)), + coldist2mat(cd.flowers)[["dS"]] + ) + jnd_xy_rot <- jnd2xyz(cd.flowers, rotate = TRUE) expect_snapshot(jnd_xy_rot) @@ -47,6 +60,13 @@ test_that("JND space for tetrachromat", { jnd_xyz <- jnd2xyz(cd.flowers, rotate = FALSE) + # After conversion to coordinates, the distance should not be modified + expect_equal( + as.matrix(dist(jnd_xyz, diag = TRUE, upper = TRUE)), + coldist2mat(cd.flowers)[["dS"]], + tolerance = 1e-6 + ) + jnd_xyz_rot <- jnd2xyz(cd.flowers, rotate = TRUE) expect_snapshot(jnd_xyz_rot)