Skip to content

Commit

Permalink
update expected vals in test-make_frames.r and doc in NEWS.md
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisholbrook committed Jan 19, 2024
1 parent 39c8b24 commit 7e2b883
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
6 changes: 4 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@

### Bug fixes and minor changes

- Add test for various inputs of `background_xlim`, `background_ylim`, and
`bg_map` to function `make_frames`.

- Fix bug introduced in glatos 0.7.0 where x and y limits were switched
when `bg_map` was supplied.
- Add test for various inputs of `background_xlim`, `background_ylim`, and
`bg_map` to function `make_frames`.


----
Expand Down
19 changes: 12 additions & 7 deletions tests/testthat/test-make_frames.r
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ pos1 <- structure(list(animal_id = c("153", "153", "153", "153"),
-83.8442607462938), record_type = c("detection", "detection",
"interpolated", "interpolated")), row.names = 4:7, class = "data.frame")


# Expected file size
size_should_be <- 30919

# Check output with default background_ylim, background_xlim, and bg_map
# make a preview image
temp_dir <- tempdir()
make_frames(pos1, out_dir=temp_dir, preview = TRUE)

# Expected file size
size_should_be1 <- 30919

# Actual file sizes
img_file1 <- file.path(temp_dir, "1.png")
img_size1 <- file.info(img_file1)$size
Expand All @@ -34,6 +33,9 @@ temp_dir <- tempdir()
make_frames(pos1, out_dir=temp_dir, preview = TRUE,
bg_map = great_lakes_polygon)

# Expected file size
size_should_be2 <- 23832

# Actual file sizes
img_file2 <- file.path(temp_dir, "1.png")
img_size2 <- file.info(img_file2)$size
Expand All @@ -54,6 +56,9 @@ make_frames(pos1,
preview = TRUE,
bg_map = great_lakes_polygon)

# Expected file size
size_should_be3 <- 32220

# Actual file sizes
img_file3 <- file.path(temp_dir, "1.png")
img_size3 <- file.info(img_file3)$size
Expand All @@ -66,16 +71,16 @@ unlink(list.files(temp_dir, full.names = TRUE, recursive = TRUE,
# Testing file size results
test_that("Expected result when background lims and map not supplied", {
# Check if expected and actual file sizes
expect_equal(img_size1, size_should_be)
expect_equal(img_size1, size_should_be1)
})

test_that("Expected result when map but not background lims supplied", {
# Check if expected and actual file sizes
expect_equal(img_size2, size_should_be)
expect_equal(img_size2, size_should_be2)
})

test_that("Expected result when map and background lims supplied", {
# Check if expected and actual file sizes
expect_equal(img_size3, size_should_be)
expect_equal(img_size3, size_should_be3)
})

0 comments on commit 7e2b883

Please sign in to comment.