Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
heike committed May 10, 2024
1 parent 0b133b5 commit 5107c95
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/testthat/test_x3p_crop.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@ test_that("x3p_crop works as expected", {
# crop to same size
expect_silent(tmp <- x3ptest_mask %>% x3p_crop(width=6,height=7))
expect_equal(tmp$general.info$Comment, "cropped from location (1,1)")
# offset element should have been added
expect_contains(names(tmp), "offset")
# offset should have two rows and five columns
expect_identical(dim(tmp$offset), c(2L,5L))

# try to crop to larger size
expect_warning(tmp <- x3ptest_mask %>% x3p_crop(width=10,height=10))
expect_warning(tmp <- x3ptest_mask %>% x3p_crop(2, 2, width=10,height=10))
expect_warning(tmp <- tmp %>% x3p_crop(1, 1, width=10,height=10))
# second crop should preserve starting location within x3ptest_mask:
expect_equal(tmp$offset$xmin[1], 2)
expect_equal(tmp$offset$ymin[1], 2)

# crop to smaller size
expect_silent(tmp <- x3ptest_mask %>% x3p_crop(width=4,height=4))

Expand Down

0 comments on commit 5107c95

Please sign in to comment.