diff --git a/DESCRIPTION b/DESCRIPTION index 09883c6..4da723c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,6 +11,7 @@ Description: Contains a number of common astronomy utility functions for cosmolo License: LGPL-3 LazyData: TRUE Depends: R (>= 3.00), RANN, NISTunits, pracma -Suggests: plotrix, igraph +Suggests: plotrix, igraph, testthat (>= 3.0.0) LinkingTo: Rcpp NeedsCompilation: yes +Config/testthat/edition: 3 diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000..520be89 --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,4 @@ +library(testthat) +library(celestial) + +test_check("celestial") diff --git a/tests/testthat/test-coordinate-matching.R b/tests/testthat/test-coordinate-matching.R new file mode 100644 index 0000000..ed94bcb --- /dev/null +++ b/tests/testthat/test-coordinate-matching.R @@ -0,0 +1,11 @@ +test_that("single-coordinate matching chooses the nearest in-radius source", { + matches <- coordmatchsing( + RAref = 0, Decref = 0, + coordcompare = rbind(c(1, 0), c(0, 0)), + rad = 2, radunit = "deg" + ) + + expect_equal(matches$ID, c(2, 1)) + expect_equal(unname(matches$bestmatch["compareID"]), 2) + expect_equal(unname(matches$bestmatch["sep"]), 0, tolerance = 1e-10) +})