Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed May 5, 2024
1 parent 14b8ec4 commit c98df38
Show file tree
Hide file tree
Showing 3 changed files with 808 additions and 78 deletions.
78 changes: 78 additions & 0 deletions tests/testthat/test-as_duckplyr_df.R
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,32 @@ test_that("as_duckplyr_df() and mutate(c = NA_character_, d = c %in% NA_characte
})


test_that("as_duckplyr_df() and mutate(d = a %in% NULL)", {
# Data
test_df <- data.frame(a = 1:6 + 0, b = 2, g = rep(1:3, 1:3))

# Run
pre <- test_df %>% as_duckplyr_df() %>% mutate(d = a %in% NULL)
post <- test_df %>% mutate(d = a %in% NULL) %>% as_duckplyr_df()

# Compare
expect_identical(pre, post)
})


test_that("as_duckplyr_df() and mutate(d = a %in% integer())", {
# Data
test_df <- data.frame(a = 1:6 + 0, b = 2, g = rep(1:3, 1:3))

# Run
pre <- test_df %>% as_duckplyr_df() %>% mutate(d = a %in% integer())
post <- test_df %>% mutate(d = a %in% integer()) %>% as_duckplyr_df()

# Compare
expect_identical(pre, post)
})


test_that("as_duckplyr_df() and mutate(d = NA_real_, e = is.na(d))", {
# Data
test_df <- data.frame(a = 1:6 + 0, b = 2, g = rep(1:3, 1:3))
Expand Down Expand Up @@ -1625,6 +1651,58 @@ test_that("as_duckplyr_df() and mutate(c = .data$b)", {
expect_identical(pre, post)
})


test_that("as_duckplyr_df() and mutate(d = NA)", {
# Data
test_df <- data.frame(a = 1:6 + 0, b = 2, g = rep(1:3, 1:3))

# Run
pre <- test_df %>% as_duckplyr_df() %>% mutate(d = NA)
post <- test_df %>% mutate(d = NA) %>% as_duckplyr_df()

# Compare
expect_identical(pre, post)
})


test_that("as_duckplyr_df() and mutate(d = NA_integer_)", {
# Data
test_df <- data.frame(a = 1:6 + 0, b = 2, g = rep(1:3, 1:3))

# Run
pre <- test_df %>% as_duckplyr_df() %>% mutate(d = NA_integer_)
post <- test_df %>% mutate(d = NA_integer_) %>% as_duckplyr_df()

# Compare
expect_identical(pre, post)
})


test_that("as_duckplyr_df() and mutate(d = NA_real_)", {
# Data
test_df <- data.frame(a = 1:6 + 0, b = 2, g = rep(1:3, 1:3))

# Run
pre <- test_df %>% as_duckplyr_df() %>% mutate(d = NA_real_)
post <- test_df %>% mutate(d = NA_real_) %>% as_duckplyr_df()

# Compare
expect_identical(pre, post)
})


test_that("as_duckplyr_df() and mutate(d = NA_character_)", {
# Data
test_df <- data.frame(a = 1:6 + 0, b = 2, g = rep(1:3, 1:3))

# Run
pre <- test_df %>% as_duckplyr_df() %>% mutate(d = NA_character_)
post <- test_df %>% mutate(d = NA_character_) %>% as_duckplyr_df()

# Compare
expect_identical(pre, post)
})

test_that("as_duckplyr_df() and n_groups()", {
withr::local_envvar(DUCKPLYR_FORCE = "FALSE")

Expand Down
Loading

0 comments on commit c98df38

Please sign in to comment.