diff --git a/tests/testthat/test-utils_join_coalesce.R b/tests/testthat/test-utils_join_coalesce.R index 2cd9a1da..72e86bbb 100644 --- a/tests/testthat/test-utils_join_coalesce.R +++ b/tests/testthat/test-utils_join_coalesce.R @@ -3,10 +3,19 @@ test_that("join coalesce function works", { x <- data.frame(id1 = c(NA_character_,letters[1:4]), a = c(1,NA,3,NA,5), b = 1:5 * 10) y <- data.frame(id2 = c(letters[3:11],NA_character_), a = -(1:10), c = 1:10 * 100) - left1 <- join_coalesce(x,y, by = c("id1"="id2")) - left2 <- join_coalesce(x,y, by.x = "id1", by.y = "id2") - inner1 <- join_coalesce(x,y, by = c("id1"="id2"), type = "inner") - full1 <- join_coalesce(x,y, by = c("id1"="id2"), type = "full") + # Keys include NAs and trigger a warning + expect_warning( + left1 <- join_coalesce(x, y, by = c("id1" = "id2")) + ) + expect_warning( + left2 <- join_coalesce(x, y, by.x = "id1", by.y = "id2") + ) + expect_warning( + inner1 <- join_coalesce(x, y, by = c("id1" = "id2"), type = "inner") + ) + expect_warning( + full1 <- join_coalesce(x, y, by = c("id1" = "id2"), type = "full") + ) expect_equal(left1,left2) # both join-by methods work the same expect_equal(sum(is.na(left1$a)), 1) # one NA on left join