Skip to content

Commit

Permalink
fixing Styler
Browse files Browse the repository at this point in the history
  • Loading branch information
sadchla-codes committed Mar 8, 2024
1 parent 5e9e189 commit a4cfc5a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
38 changes: 20 additions & 18 deletions tests/testthat/test-format.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ test_that(
)

## Test 7: xportr_format: If a variable is character then a warning should be produced if format is > 32 in length ----
test_that("format Test 7: If a variable is character then a warning should be produced if format is > 32 in length", {#nolint
test_that("format Test 7: If a variable is character then a warning should be produced if format is > 32 in length", { # nolint
adsl <- data.frame(
USUBJID = c("1001", "1002", "1003"),
BRTHDT = c(1, 1, 2)
Expand Down Expand Up @@ -151,27 +151,29 @@ test_that("format Test 7: If a variable is character then a warning should be pr

## Test 8: xportr_format: If a variable is numeric then an error should be produced if a format starts with `$` ----
test_that(
"format Test 8: If a variable is numeric then an error should be produced if a format starts with `$`", {#nolint
adsl <- data.frame( #nolint
USUBJID = c(1001, 1002, 1003),
BRTHDT = c(1, 1, 2)
)
"format Test 8: If a variable is numeric then an error should be produced if a format starts with `$`",
{ # nolint
adsl <- data.frame( # nolint
USUBJID = c(1001, 1002, 1003),
BRTHDT = c(1, 1, 2)
)

metadata <- data.frame( #nolint
dataset = c("adsl", "adsl"),
variable = c("USUBJID", "BRTHDT"),
format = c("$4.", "DATE9.")
)
metadata <- data.frame( # nolint
dataset = c("adsl", "adsl"),
variable = c("USUBJID", "BRTHDT"),
format = c("$4.", "DATE9.")
)

expect_error( #nolint
xportr_format(adsl, metadata, verbose = "stop"),
regexp = "(xportr::xportr_format) `USUBJID` is a numeric variable and should not have a `$` prefix.",
fixed = TRUE
)
})
expect_error( # nolint
xportr_format(adsl, metadata, verbose = "stop"),
regexp = "(xportr::xportr_format) `USUBJID` is a numeric variable and should not have a `$` prefix.",
fixed = TRUE
)
}
)

## Test 9: xportr_format: If a variable is numeric then a warning should be produced if format is > 32 in length ---- #nolint
test_that("format Test 9: If a variable is numeric then a warning should be produced if format is > 32 in length", { #nolint
test_that("format Test 9: If a variable is numeric then a warning should be produced if format is > 32 in length", { # nolint
adsl <- data.frame(
USUBJID = c(1001, 1002, 1003),
BRTHDT = c(1, 1, 2)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-order.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ test_that("order Test 8: Variable ordering messaging is correct", {
)

suppressMessages(xportr_order(df2, df_meta, verbose = "message", domain = "df2") %>%
expect_message("2 variables not in spec and moved to end") %>% #nolint
expect_message("2 variables not in spec and moved to end") %>% # nolint
expect_message("Variable moved to end in `.df`: `a` and `z`") %>%
expect_message("All variables in dataset are ordered"))
})
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-utils-xportr.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ test_that("utils-xportr Test 4: Get error message when the variable is over 8 ch
})

## Test 5: xpt_validate_var_names: Get error message when the variable does not start with a letter ----
test_that("utils-xportr Test 5: Get error message when the variable does not start with a letter", { #nolint
test_that("utils-xportr Test 5: Get error message when the variable does not start with a letter", { # nolint
expect_equal(
xpt_validate_var_names(c("FOO", "2BAR")), #nolint
xpt_validate_var_names(c("FOO", "2BAR")), # nolint
"Variable `2BAR` must start with a letter."
)
})
Expand Down Expand Up @@ -133,7 +133,7 @@ test_that("utils-xportr Test 12: Get error message when the length of a non-ASCI
})

## Test 13: xpt_validate: Get error message when the length of a character variable is > 200 bytes and contains NAs ----
test_that("utils-xportr Test 13: Get error message when the length of a character variable is > 200 bytes and contains NAs", { #nolint
test_that("utils-xportr Test 13: Get error message when the length of a character variable is > 200 bytes and contains NAs", { # nolint
df <- data.frame(A = c(paste(rep("A", 201), collapse = ""), NA_character_))
expect_equal(
xpt_validate(df),
Expand Down

0 comments on commit a4cfc5a

Please sign in to comment.