Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Jun 14, 2020
1 parent 0cbd592 commit 06ba0de
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/testthat/subsetting.txt
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,23 @@ Error: Must extract column with a single valid subscript.
x Subscript `TRUE` has the wrong type `logical`.
i It must be numeric or character.

> foo[[-1]]
Error: Must extract column with a single valid subscript.
x Subscript `-1` has value -1 but must be a positive location.

> foo[[1.5]]
Error: Must extract column with a single valid subscript.
x Can't convert from `1.5` <double> to <integer> due to loss of precision.

> foo[[3]]
Error: Can't subset columns that don't exist.
x Location 3 doesn't exist.
i There are only 2 columns.

> foo[[Inf]]
Error: Must extract column with a single valid subscript.
x Can't convert from `Inf` <double> to <integer> due to loss of precision.

> foo[[mean]]
Error: Must extract column with a single valid subscript.
x Subscript `mean` has the wrong type `function`.
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-subsetting.R
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,10 @@ verify_output("subsetting.txt", {
foo[[1:3]]
foo[[ letters[1:3] ]]
foo[[TRUE]]
foo[[-1]]
foo[[1.5]]
foo[[3]]
foo[[Inf]]
foo[[mean]]
foo[[foo]]

Expand Down

0 comments on commit 06ba0de

Please sign in to comment.