test_that("the R and C++ shared-neighbor implementations agree", { data <- rbind( c(0, 0), c(0, 1), c(1, 0), c(1, 1), c(3, 3), c(3, 4) ) invisible(capture.output( reference <- SharedNeighbor_Distance( data, k = 2, NThreads = 1, ComputationInR = TRUE ) )) invisible(capture.output( observed <- SharedNeighbor_Distance( data, k = 2, NThreads = 1, ComputationInR = FALSE ) )) expect_equal(observed, reference) expect_equal(observed, t(observed)) expect_equal(diag(observed), rep(0, nrow(data))) })