Skip to content

Commit

Permalink
additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
larmarange committed Oct 3, 2024
1 parent 1737d76 commit bcf950e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/testthat/test-labelled.r
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,26 @@ test_that("null_action in var_label() works as expected", {
Species = "Species"
)
)
expect_equal(
var_label(df, null_action = "na"),
list(
Sepal.Length = NA_character_,
Sepal.Width = NA_character_,
Petal.Length = "length of petal",
Petal.Width = "width of petal",
Species = NA_character_
)
)
expect_equal(
var_label(df, null_action = "empty"),
list(
Sepal.Length = "",
Sepal.Width = "",
Petal.Length = "length of petal",
Petal.Width = "width of petal",
Species = ""
)
)
expect_equal(
var_label(df, null_action = "skip"),
list(
Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/test-update_with.r
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ test_that("update_variable_labels_with() works as expected", {
expect_equal(var_label(tmp$Species), "SPECIES")
expect_equal(var_label(tmp$Sepal.Length), "LENGTH OF SEPAL")
expect_equal(var_label(tmp$Petal.Width), "Width of petal")

tmp <- df %>%
update_variable_labels_with(~ tolower(names(.x)))
expect_equal(var_label(tmp$Species), "species")
expect_equal(var_label(tmp$Sepal.Length), "sepal.length")

tmp <- iris %>%
update_variable_labels_with(~ tolower(names(.x)))
expect_equal(var_label(tmp$Species), "species")
expect_equal(var_label(tmp$Sepal.Length), "sepal.length")
})

test_that("update_value_labels_with() works as expected", {
Expand Down

0 comments on commit bcf950e

Please sign in to comment.