Skip to content

Commit

Permalink
Tweak error testing
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Nov 29, 2023
1 parent 6fb3ab5 commit 9849619
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
16 changes: 15 additions & 1 deletion tests/testthat/_snaps/xml_find.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,21 @@

# xml_find_int errors with non integer results

Element at path `//z` must be a whole number, not a <xml_missing> object.
Code
xml_find_int(x, "//z")
Condition
Error in `xml_find_int()`:
! Element at path `//z` must be a whole number, not a <xml_missing> object.
Code
xml_find_int(x, "//y")
Condition
Error in `xml_find_int()`:
! Element at path `//y` must be a whole number, not a list.
Code
xml_find_int(x, "number(1.1)")
Condition
Error in `xml_find_int()`:
! Element at path `number(1.1)` must be a whole number, not the number 1.1.

# xml_find_chr errors with non character results

Expand Down
4 changes: 1 addition & 3 deletions tests/testthat/test-xml_find.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,9 @@ test_that("xml_find_num returns a numeric result", {
# Find int ---------------------------------------------------------------------
test_that("xml_find_int errors with non integer results", {
x <- read_xml("<x><y/><y/></x>")
expect_snapshot_error({
expect_snapshot(error = TRUE, {
xml_find_int(x, "//z")
xml_find_int(x, "//y")
xml_find_int(x, "1=1")
xml_find_int(x, "string(5)")
xml_find_int(x, "number(1.1)")
})
})
Expand Down

0 comments on commit 9849619

Please sign in to comment.