Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Melkiades committed Jan 19, 2024
1 parent 602dec9 commit e016c17
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/testthat/test-paginate_listing.R
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,35 @@ testthat::test_that("paginate_to_mpfs works with wrapping on keycols", {
seq(8, 6)
)
})

testthat::test_that("paginate_to_mpfs works with wrapping on keycols when doing horizontal pagination", {
iris2 <- iris[1:10, 3:5]
iris2$Species <- "SOMETHING VERY LONG THAT BREAKS PAGINATION"
iris2 <- cbind("Petal.L3ngth" = iris2$Petal.Length, iris2)

lst <- as_listing(iris2, key_cols = c("Species", "Petal.Width"))
cw <- propose_column_widths(lst)
cw[1] <- 30
colgap <- matrix_form(lst)$col_gap
expected_min_cpp <- sum(cw[seq_len(3)]) + 2 * colgap
pgs <- paginate_to_mpfs(lst, colwidths = cw, lpp = 150, cpp = expected_min_cpp + 3) # why + 3? -> + colgap

testthat::expect_equal(
sapply(pgs, function(x) strsplit(toString(x), "\n")[[1]][1] %>% nchar()),
rep(expected_min_cpp, 2) # no colgap
)

pgs <- paginate_to_mpfs(lst, colwidths = cw, lpp = 5, cpp = expected_min_cpp + 3)

# testing nrow
testthat::expect_equal(
sapply(pgs, function(x) strsplit(toString(x), "\n")[[1]] %>% length()),
rep(5, 10)
)
# testing nchars
testthat::expect_equal(
sapply(pgs, function(x) strsplit(toString(x), "\n")[[1]][1] %>% nchar()),
rep(expected_min_cpp, 10)
)

})

0 comments on commit e016c17

Please sign in to comment.