diff --git a/tests/testthat/_snaps/xml_nodeset.md b/tests/testthat/_snaps/xml_nodeset.md index 7367ec6..acca461 100644 --- a/tests/testthat/_snaps/xml_nodeset.md +++ b/tests/testthat/_snaps/xml_nodeset.md @@ -15,3 +15,22 @@ [9]
More
[10] +--- + + Code + print(x, width = 13L) + Output + {xml_document} + + [1] 123 ... + [2] 123 ... + [3] 12\ ... + Code + print(x, width = 14L) + Output + {xml_document} + + [1] 1234 ... + [2] 1234 ... + [3] 12\\ ... + diff --git a/tests/testthat/test-xml_nodeset.R b/tests/testthat/test-xml_nodeset.R index 81382fb..cb796bd 100644 --- a/tests/testthat/test-xml_nodeset.R +++ b/tests/testthat/test-xml_nodeset.R @@ -72,8 +72,24 @@ test_that("methods work on empty nodesets", { }) test_that("print method is correct", { + skip_if(getOption("width") < 20L, "Screen too narrow") + x <- read_html(test_path("lego.html.bz2")) body <- xml_find_first(x, "//body") divs <- xml_find_all(body, ".//div")[1:10] expect_snapshot(print(divs)) + + # double-substring() logic + s <- c( + "123456789\\", # always too wide, '\' never encoded + "12345", # always fits + "12\\45" # doesn't fit when '\' is encoded + ) + # embed as text on nodes ,, + s <- sprintf("<%1$s>%2$s", letters[1:3], s) + x <- read_xml(sprintf("%s", paste(s, collapse=""))) + expect_snapshot({ + print(x, width = 13L) + print(x, width = 14L) + }) })