Skip to content

Commit

Permalink
Merge branch 'master' into summary-rows-vignette
Browse files Browse the repository at this point in the history
* master:
  Store empty-string value in `sep` vector (#274)
  • Loading branch information
rich-iannone committed Apr 25, 2019
2 parents 3306df0 + ad55d8c commit c2f524d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
6 changes: 6 additions & 0 deletions R/modify_columns.R
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,9 @@ cols_merge <- function(data,
attr(data, "col_merge")[["pattern"]] <-
c(attr(data, "col_merge")[["pattern"]], pattern)

attr(data, "col_merge")[["sep"]] <-
c(attr(data, "col_merge")[["sep"]], "")

attr(data, "col_merge")[["col_1"]] <-
c(attr(data, "col_merge")[["col_1"]], col_1)

Expand Down Expand Up @@ -878,6 +881,9 @@ cols_merge_uncert <- function(data,
attr(data, "col_merge")[["pattern"]] <-
c(attr(data, "col_merge")[["pattern"]], pattern)

attr(data, "col_merge")[["sep"]] <-
c(attr(data, "col_merge")[["sep"]], "")

attr(data, "col_merge")[["col_1"]] <-
c(attr(data, "col_merge")[["col_1"]], col_val)

Expand Down
30 changes: 30 additions & 0 deletions tests/testthat/test-cols_merge.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ test_that("the function `cols_merge()` works correctly", {
attr(tbl_html, "col_merge", exact = TRUE)$pattern %>%
expect_equal("{1} ({2})")

attr(tbl_html, "col_merge", exact = TRUE)$sep %>%
expect_equal("")

attr(tbl_html, "col_merge", exact = TRUE)$col_1 %>%
names() %>%
expect_equal("wt")
Expand All @@ -63,6 +66,9 @@ test_that("the function `cols_merge()` works correctly", {
attr(tbl_html, "col_merge", exact = TRUE)$pattern %>%
expect_equal("{1} ({2})")

attr(tbl_html, "col_merge", exact = TRUE)$sep %>%
expect_equal("")

attr(tbl_html, "col_merge", exact = TRUE)$col_1 %>%
names() %>%
expect_equal("wt")
Expand All @@ -88,6 +94,9 @@ test_that("the function `cols_merge()` works correctly", {
attr(tbl_html, "col_merge", exact = TRUE)$pattern[[1]] %>%
expect_equal("{1} ({2})")

attr(tbl_html, "col_merge", exact = TRUE)$sep[[1]] %>%
expect_equal("")

attr(tbl_html, "col_merge", exact = TRUE)$col_1[1] %>%
names() %>%
expect_equal("wt")
Expand All @@ -99,6 +108,9 @@ test_that("the function `cols_merge()` works correctly", {
attr(tbl_html, "col_merge", exact = TRUE)$pattern[[2]] %>%
expect_equal("{1}-{2}")

attr(tbl_html, "col_merge", exact = TRUE)$sep[[2]] %>%
expect_equal("")

attr(tbl_html, "col_merge", exact = TRUE)$col_1[2] %>%
names() %>%
expect_equal("carb")
Expand All @@ -125,6 +137,9 @@ test_that("the `cols_merge_uncert()` function works correctly", {
attr(tbl_html, "col_merge", exact = TRUE)$pattern %>%
expect_equal("{1} ± {2}")

attr(tbl_html, "col_merge", exact = TRUE)$sep %>%
expect_equal("")

attr(tbl_html, "col_merge", exact = TRUE)$col_1 %>%
names() %>%
expect_equal("col_2")
Expand All @@ -145,6 +160,9 @@ test_that("the `cols_merge_uncert()` function works correctly", {
attr(tbl_html, "col_merge", exact = TRUE)$pattern %>%
expect_equal("{1} ± {2}")

attr(tbl_html, "col_merge", exact = TRUE)$sep %>%
expect_equal("")

attr(tbl_html, "col_merge", exact = TRUE)$col_1 %>%
names() %>%
expect_equal("col_2")
Expand All @@ -168,6 +186,9 @@ test_that("the `cols_merge_uncert()` function works correctly", {
attr(tbl_html, "col_merge", exact = TRUE)$pattern[[1]] %>%
expect_equal("{1} ± {2}")

attr(tbl_html, "col_merge", exact = TRUE)$sep[[1]] %>%
expect_equal("")

attr(tbl_html, "col_merge", exact = TRUE)$col_1[1] %>%
names() %>%
expect_equal("col_2")
Expand All @@ -179,6 +200,9 @@ test_that("the `cols_merge_uncert()` function works correctly", {
attr(tbl_html, "col_merge", exact = TRUE)$pattern[[2]] %>%
expect_equal("{1} ± {2}")

attr(tbl_html, "col_merge", exact = TRUE)$sep[[2]] %>%
expect_equal("")

attr(tbl_html, "col_merge", exact = TRUE)$col_1[2] %>%
names() %>%
expect_equal("col_4")
Expand All @@ -205,6 +229,9 @@ test_that("the `cols_merge_range()` function works correctly", {
attr(tbl_html, "col_merge", exact = TRUE)$pattern %>%
expect_equal("{1} {sep} {2}")

attr(tbl_html, "col_merge", exact = TRUE)$sep %>%
expect_equal("---")

attr(tbl_html, "col_merge", exact = TRUE)$col_1 %>%
names() %>%
expect_equal("col_2")
Expand All @@ -225,6 +252,9 @@ test_that("the `cols_merge_range()` function works correctly", {
attr(tbl_html, "col_merge", exact = TRUE)$pattern %>%
expect_equal("{1} {sep} {2}")

attr(tbl_html, "col_merge", exact = TRUE)$sep %>%
expect_equal("---")

attr(tbl_html, "col_merge", exact = TRUE)$col_1 %>%
names() %>%
expect_equal("col_2")
Expand Down

0 comments on commit c2f524d

Please sign in to comment.