Skip to content

Commit

Permalink
additions
Browse files Browse the repository at this point in the history
  • Loading branch information
Melkiades committed Oct 15, 2023
1 parent 26327c6 commit 2e4cae5
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions tests/testthat/test-printing.R
Original file line number Diff line number Diff line change
Expand Up @@ -545,19 +545,22 @@ test_that("row label indentation is kept even if there are newline characters",
})

test_that("Support for newline characters in all the parts", {
set.seed(1)
DM_trick <- DM %>%
mutate(ARM2 = sample(c("TWO\nwords\n", "A wo\n\nrd"), replace = TRUE, nrow(DM))) # last \n is eaten up
mutate(ARM2 = sample(c("TWO\nwords\n", "A wo\n\nrd"),
replace = TRUE, nrow(DM))) # last \n is eaten up
levels(DM_trick$SEX)[3] <- "U\nN\nD\n"
tbl <- basic_table() %>%
split_rows_by("SEX", split_label = "m\nannaggia\nsda\n", label_pos = "visible") %>% # last \n bug
split_rows_by("SEX", split_label = "m\nannaggia\nsda\n",
label_pos = "visible") %>% # last \n bug
split_cols_by("ARM2", split_label = "sda") %>%
analyze("BMRKR1", na_str = "asd\nasd") %>% # \n error
build_table(DM_trick)

top_left(tbl) <- c("a", "b\nd\n\n", "c\n\n") # last \n is eaten up, if in the middle error
main_title(tbl) <- "why not \nalso here\n"
# matrix_form(tbl)
# to_string_matrix2(tbl, hsep = "-", with_spaces = TRUE, print_txt_to_copy = TRUE)
to_string_matrix2(tbl, hsep = "-", with_spaces = TRUE, print_txt_to_copy = TRUE)
out <- strsplit(toString(tbl, hsep = "-"), "\\n")[[1]]
expected <- c(
"why not ",
Expand All @@ -569,26 +572,26 @@ test_that("Support for newline characters in all the parts", {
"b ",
"d ",
" ",
" A wo ",
"c TWO ",
" rd words",
"c A wo",
" TWO ",
" words rd ",
"---------------------------------",
"m ",
"annaggia ",
"sda ",
" F ",
" Mean 5.95 6.13 ",
" Mean 5.81 6.29",
" M ",
" Mean 5.82 5.46 ",
" Mean 6.15 5.21",
" U ",
" N ",
" D ",
" ",
" Mean asd asd ",
" asd asd ",
" Mean asd asd ",
" asd asd ",
" UNDIFFERENTIATED ",
" Mean asd asd ",
" asd asd "
" Mean asd asd ",
" asd asd "
)
expect_identical(out, expected)
})
})

0 comments on commit 2e4cae5

Please sign in to comment.