Skip to content

Commit 150425b

Browse files
expect_snapshot() over expect_error()
1 parent ac0acbc commit 150425b

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# at least one argument is required
2+
3+
Code
4+
expect_shape(1:10)
5+
Condition
6+
Error in `expect_shape()`:
7+
! Exactly one of `length`, `nrow`, `ncol`, or `dim` must be provided.
8+
9+
---
10+
11+
Code
12+
expect_shape(1:10, 2)
13+
Condition
14+
Error in `expect_shape()`:
15+
! Exactly one of `length`, `nrow`, `ncol`, or `dim` must be provided.
16+
17+
---
18+
19+
Code
20+
expect_shape(1:10, nrow = 1L, ncol = 2L)
21+
Condition
22+
Error in `expect_shape()`:
23+
! Exactly one of `length`, `nrow`, `ncol`, or `dim` must be provided.
24+

tests/testthat/test-expect-shape.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ test_that("returns input", {
3737

3838
test_that("at least one argument is required", {
3939
err_msg <- "Exactly one of `length`, `nrow`, `ncol`, or `dim` must be provided."
40-
expect_error(expect_shape(1:10), err_msg, fixed = TRUE) # no args
41-
expect_error(expect_shape(1:10, 2), err_msg, fixed = TRUE) # no named args
42-
expect_error(expect_shape(1:10, nrow = 1L, ncol = 2L), err_msg, fixed = TRUE) # multiple named args
40+
expect_snapshot(expect_shape(1:10), error = TRUE) # no args
41+
expect_snapshot(expect_shape(1:10, 2), error = TRUE) # no named args
42+
expect_snapshot(expect_shape(1:10, nrow = 1L, ncol = 2L), error = TRUE) # multiple named args
4343
})

0 commit comments

Comments
 (0)