Skip to content

Commit

Permalink
Partial match (#992)
Browse files Browse the repository at this point in the history
* avoid partial matching

* Add the slowest tests to start first!

* Update R/helper-functions.R

* Update helper-functions.R
  • Loading branch information
olivroy committed Apr 12, 2024
1 parent 4bfa2fd commit acfe449
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 17 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ RoxygenNote: 7.3.1
Roxygen: list(markdown = TRUE)
Config/testthat/edition: 3
Config/testthat/parallel: true
Config/testthat/start-first: read_sources, class-workbook-wrappers
2 changes: 1 addition & 1 deletion R/class-workbook.R
Original file line number Diff line number Diff line change
Expand Up @@ -3518,7 +3518,7 @@ wbWorkbook <- R6::R6Class(

if (any(ind)) {
nn <- sprintf("'%s'", new_name[i])
nn <- stringi::stri_replace_all_fixed(self$workbook$definedName[ind], old, nn)
nn <- stringi::stri_replace_all_fixed(self$workbook$definedNames[ind], old, nn)
nn <- stringi::stri_replace_all(nn, regex = "'+", replacement = "'")
self$workbook$definedNames[ind] <- nn
}
Expand Down
2 changes: 1 addition & 1 deletion R/get-named-regions.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ get_nr_from_definedName <- function(wb) {
get_named_regions_tab <- function(wb) {
data.frame(
#localSheetId is not always available
name = wb$tables$tab_nam,
name = wb$tables$tab_name,
value = "table",
sheets = wb_get_sheet_name(wb, wb$tables$tab_sheet),
coords = wb$tables$tab_ref,
Expand Down
2 changes: 1 addition & 1 deletion R/helper-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ get_colstyle <- function(wb, sheet = current_sheet()) {
st_ids <- NULL
if (length(wb$worksheets[[sheet]]$cols_attr)) {
cols <- wb$worksheets[[sheet]]$unfold_cols()
st_ids <- cols$s[cols$s != ""]
st_ids <- cols$style[cols$style != ""]
xf_ids <- match(st_ids, wb$styles_mgr$xf$id)
xf_xml <- wb$styles_mgr$styles$cellXfs[xf_ids]
} else {
Expand Down
12 changes: 6 additions & 6 deletions R/write.R
Original file line number Diff line number Diff line change
Expand Up @@ -475,12 +475,12 @@ write_data2 <- function(
}

wb$add_font(
sheet = sheetno,
dims = dim_sel,
color = hyperlink_col,
name = wb_get_base_font(wb)$name$val,
size = wb_get_base_font(wb)$size$val,
u = "single"
sheet = sheetno,
dims = dim_sel,
color = hyperlink_col,
name = wb$get_base_font()$name$val,
size = wb$get_base_font()$size$val,
underline = "single"
)
}

Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-class-comment.R
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ test_that("background images work", {

# file extension must be png or jpeg, not jpg?
tmp <- tempfile(fileext = ".png")
png(file = tmp, bg = "transparent")
png(filename = tmp, bg = "transparent")
plot(1:10)
rect(1, 5, 3, 7, col = "white")
dev.off()
Expand All @@ -320,7 +320,7 @@ test_that("background images work", {

# file extension must be png or jpeg, not jpg?
tmp2 <- tempfile(fileext = ".png")
png(file = tmp2, bg = "transparent")
png(filename = tmp2, bg = "transparent")
barplot(1:10)
dev.off()

Expand All @@ -340,7 +340,7 @@ test_that("background images work", {
test_that("More than two background images work", {

tmp <- tempfile(fileext = ".png")
png(file = tmp, bg = "transparent")
png(filename = tmp, bg = "transparent")
plot(1:10)
dev.off()

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-class-workbook-wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ test_that("wb_get_tables(), wb_remove_tables() are wrappers", {

test_that("wb_add_filter(), wb_remove_filter() is a wrapper", {
wb <- wb_workbook()$add_worksheet("a")
params <- list(sheet = "a", col = 1, row = 1)
params <- list(sheet = "a", cols = 1, rows = 1)
expect_wrapper("add_filter", wb = wb, params = params)
wb$add_filter("a", 1, 1)
expect_wrapper("remove_filter", wb = wb, params = list(sheet = "a"))
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-class-workbook.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ test_that("wb_set_col_widths", {
)

# a few more errors
expect_error(wb$set_col_widths("test", cols = "Y", width = 1:2))
expect_error(wb$set_col_widths("test", cols = "Y", widths = 1:2))
expect_error(wb$set_col_widths("test", cols = "Y", hidden = 1:2))




wb <- wb_workbook()$
add_worksheet()$
set_col_widths(cols = 1:10, width = (8:17) + .5)$
set_col_widths(cols = 1:10, widths = (8:17) + .5)$
add_data(x = rbind(8:17), colNames = FALSE)

exp <- c(
Expand All @@ -72,7 +72,7 @@ test_that("wb_set_col_widths", {
"<col min=\"18\" max=\"16384\" width=\"8.88671875\" style=\"16\"/>"
)

expect_silent(wb$set_col_widths(cols = 19, width = 9))
expect_silent(wb$set_col_widths(cols = 19, widths = 9))

})

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-styles_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ test_that("dxf", {
exp <- c("font", "fill", "alignment", "border", "extLst", "numFmt",
"protection")

input <- wb$styles_mgr$styles$dxf
input <- wb$styles_mgr$styles$dxfs
got <- read_dxf(as_xml(input))
expect_equal(sort(exp), sort(names(got)))

Expand Down

0 comments on commit acfe449

Please sign in to comment.