forked from irinagain/iglu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed the bug for choosing PGS / All_metrics option with Sleep/Awake time calculations in shiny server implementatons. Added a test file for range_glu.
- Loading branch information
1 parent
95bd83a
commit 4ddc598
Showing
2 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Simple test | ||
test_data <- data.frame( | ||
id = c(1, 1, 1, 2, 2, 2), | ||
gl = c(100, 120, NA, 140, 160, 180), | ||
time = c("08:00", "12:00", "16:00") | ||
) | ||
|
||
|
||
test_that("range_glu calculates correct range for each id", { | ||
result <- range_glu(test_data) | ||
expect_equal(result$range[result$id == 1], 20) | ||
expect_equal(result$range[result$id == 2], 40) | ||
}) | ||
|
||
# All values are the same | ||
test_data_same <- data.frame( | ||
id = c(1, 1, 1), | ||
gl = c(100, 100, 100), | ||
time = c("08:00", "12:00", "16:00") | ||
) | ||
|
||
test_that("range_glu handles all values the same correctly", { | ||
result <- range_glu(test_data_same) | ||
expect_equal(result$range, c(0)) | ||
}) |