From 984961965da2583e010fb79122e9950cfa71594a Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Wed, 29 Nov 2023 16:12:20 -0600 Subject: [PATCH] Tweak error testing --- tests/testthat/_snaps/xml_find.md | 16 +++++++++++++++- tests/testthat/test-xml_find.R | 4 +--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/testthat/_snaps/xml_find.md b/tests/testthat/_snaps/xml_find.md index aff52604..7d1f0ebe 100644 --- a/tests/testthat/_snaps/xml_find.md +++ b/tests/testthat/_snaps/xml_find.md @@ -4,7 +4,21 @@ # xml_find_int errors with non integer results - Element at path `//z` must be a whole number, not a object. + Code + xml_find_int(x, "//z") + Condition + Error in `xml_find_int()`: + ! Element at path `//z` must be a whole number, not a 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 diff --git a/tests/testthat/test-xml_find.R b/tests/testthat/test-xml_find.R index 1fbfdd31..2311d98b 100644 --- a/tests/testthat/test-xml_find.R +++ b/tests/testthat/test-xml_find.R @@ -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("") - 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)") }) })