Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilHvitfeldt committed May 17, 2024
1 parent 7672fd8 commit bcad62b
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/testthat/_snaps/sparse_character.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,22 @@
x `positions` must not contain NaN values.
i NaN values at index: 1.

---

Code
sparse_character(numeric(0), integer(0), -10)
Condition
Error in `sparse_character()`:
! `length` must be a whole number larger than or equal to 0, not the number -10.

---

Code
sparse_character(numeric(0), integer(0), 1e+10)
Condition
Error in `sparse_character()`:
! `length` must be less than 2147483647, not 1e+10.

---

Code
Expand Down
16 changes: 16 additions & 0 deletions tests/testthat/_snaps/sparse_double.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,22 @@
x `positions` must not contain NaN values.
i NaN values at index: 1.

---

Code
sparse_double(numeric(0), integer(0), -10)
Condition
Error in `sparse_double()`:
! `length` must be a whole number larger than or equal to 0, not the number -10.

---

Code
sparse_double(numeric(0), integer(0), 1e+10)
Condition
Error in `sparse_double()`:
! `length` must be less than 2147483647, not 1e+10.

---

Code
Expand Down
16 changes: 16 additions & 0 deletions tests/testthat/_snaps/sparse_integer.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,22 @@
x `positions` must not contain NaN values.
i NaN values at index: 1.

---

Code
sparse_integer(numeric(0), integer(0), -10)
Condition
Error in `sparse_integer()`:
! `length` must be a whole number larger than or equal to 0, not the number -10.

---

Code
sparse_integer(numeric(0), integer(0), 1e+10)
Condition
Error in `sparse_integer()`:
! `length` must be less than 2147483647, not 1e+10.

---

Code
Expand Down
16 changes: 16 additions & 0 deletions tests/testthat/_snaps/sparse_logical.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,22 @@
x `positions` must not contain NaN values.
i NaN values at index: 1.

---

Code
sparse_logical(numeric(0), integer(0), -10)
Condition
Error in `sparse_logical()`:
! `length` must be a whole number larger than or equal to 0, not the number -10.

---

Code
sparse_logical(numeric(0), integer(0), 1e+10)
Condition
Error in `sparse_logical()`:
! `length` must be less than 2147483647, not 1e+10.

---

Code
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-sparse_character.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ test_that("input checking is done correctly", {
expect_no_error(
sparse_character(character(0), integer(0), 0)
)
expect_snapshot(
error = TRUE,
sparse_character(numeric(0), integer(0), -10)
)
expect_snapshot(
error = TRUE,
sparse_character(numeric(0), integer(0), 10000000000)
)
expect_snapshot(
error = TRUE,
sparse_character(character(0), integer(0), c(1, 10))
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-sparse_double.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ test_that("input checking is done correctly", {
expect_no_error(
sparse_double(numeric(0), integer(0), 0)
)
expect_snapshot(
error = TRUE,
sparse_double(numeric(0), integer(0), -10)
)
expect_snapshot(
error = TRUE,
sparse_double(numeric(0), integer(0), 10000000000)
)
expect_snapshot(
error = TRUE,
sparse_double(numeric(0), integer(0), c(1, 10))
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-sparse_integer.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ test_that("input checking is done correctly", {
expect_no_error(
sparse_integer(integer(0), integer(0), 0)
)
expect_snapshot(
error = TRUE,
sparse_integer(numeric(0), integer(0), -10)
)
expect_snapshot(
error = TRUE,
sparse_integer(numeric(0), integer(0), 10000000000)
)
expect_snapshot(
error = TRUE,
sparse_integer(integer(0), integer(0), c(1, 10))
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-sparse_logical.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ test_that("input checking is done correctly", {
expect_no_error(
sparse_logical(logical(0), integer(0), 0)
)
expect_snapshot(
error = TRUE,
sparse_logical(numeric(0), integer(0), -10)
)
expect_snapshot(
error = TRUE,
sparse_logical(numeric(0), integer(0), 10000000000)
)
expect_snapshot(
error = TRUE,
sparse_logical(logical(0), integer(0), c(1, 10))
Expand Down

0 comments on commit bcad62b

Please sign in to comment.