Skip to content

Commit

Permalink
add correct snapshot test
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Oct 2, 2024
1 parent 489b8bb commit be756b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 9 additions & 10 deletions tests/testthat/_snaps/categorize.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,16 @@
[31] (10.4-15) (21-24.4)
Levels: (10.4-15) (15.2-19.7) (21-24.4) (26-27.3) (30.4-33.9)

---
# categorize breaks

Code
categorize(mtcars$mpg, "equal_length", n_groups = 5, labels = "observed",
breaks = "inclusive")
categorize(mtcars$mpg, "equal_length", n_groups = 5, labels = "range", breaks = "inclusive")
Output
[1] (21-24.4) (21-24.4) (21-24.4) (21-24.4) (15.2-19.7) (15.2-19.7)
[7] (10.4-15) (21-24.4) (21-24.4) (15.2-19.7) (15.2-19.7) (15.2-19.7)
[13] (15.2-19.7) (15.2-19.7) (10.4-15) (10.4-15) (10.4-15) (30.4-33.9)
[19] (30.4-33.9) (30.4-33.9) (21-24.4) (15.2-19.7) (15.2-19.7) (10.4-15)
[25] (15.2-19.7) (26-27.3) (26-27.3) (30.4-33.9) (15.2-19.7) (15.2-19.7)
[31] (10.4-15) (21-24.4)
Levels: (10.4-15) (15.2-19.7) (21-24.4) (26-27.3) (30.4-33.9)
[1] (19.8,24.5] (19.8,24.5] (19.8,24.5] (19.8,24.5] (15.1,19.8] (15.1,19.8]
[7] [10.4,15.1] (19.8,24.5] (19.8,24.5] (15.1,19.8] (15.1,19.8] (15.1,19.8]
[13] (15.1,19.8] (15.1,19.8] [10.4,15.1] [10.4,15.1] [10.4,15.1] (29.2,33.9]
[19] (29.2,33.9] (29.2,33.9] (19.8,24.5] (15.1,19.8] (15.1,19.8] [10.4,15.1]
[25] (15.1,19.8] (24.5,29.2] (24.5,29.2] (29.2,33.9] (15.1,19.8] (15.1,19.8]
[31] [10.4,15.1] (19.8,24.5]
Levels: [10.4,15.1] (15.1,19.8] (19.8,24.5] (24.5,29.2] (29.2,33.9]

2 changes: 1 addition & 1 deletion tests/testthat/test-categorize.R
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ test_that("categorize labelling ranged", {

test_that("categorize breaks", {
data(mtcars)
expect_snapshot(categorize(mtcars$mpg, "equal_length", n_groups = 5, labels = "observed", breaks = "inclusive"))
expect_snapshot(categorize(mtcars$mpg, "equal_length", n_groups = 5, labels = "range", breaks = "inclusive"))
expect_error(
categorize(mtcars$mpg, "equal_length", n_groups = 5, breaks = "something"),
regex = "should be one of"
Expand Down

0 comments on commit be756b6

Please sign in to comment.