-
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.
- Loading branch information
1 parent
f50e6b5
commit 50975cf
Showing
8 changed files
with
169 additions
and
21 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
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,14 @@ | ||
Acta | ||
CMD | ||
De | ||
Janssen | ||
Lifecycle | ||
Microchim | ||
Raedt | ||
Schalm | ||
Trivariate | ||
Veeckman | ||
magrittr | ||
th | ||
tibble | ||
trivariate |
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,3 @@ | ||
if(requireNamespace('spelling', quietly = TRUE)) | ||
spelling::spell_check_test(vignettes = TRUE, error = FALSE, | ||
skip_on_cran = TRUE) |
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,12 @@ | ||
# This file is part of the standard setup for testthat. | ||
# It is recommended that you do not modify it. | ||
# | ||
# Where should you do additional test configuration? | ||
# Learn more about the roles of various files in: | ||
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview | ||
# * https://testthat.r-lib.org/articles/special-files.html | ||
|
||
library(testthat) | ||
library(ConfidenceEllipse) | ||
|
||
test_check("ConfidenceEllipse") |
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,57 @@ | ||
library(tibble) | ||
data("glass", package = "ConfidenceEllipse") | ||
# Test cases covered: | ||
# confidence_ellipse function stops when no data is provided. | ||
# confidence_ellipse function stops when input data is not a data frame or tibble. | ||
# confidence_ellipse function stops when the conf_level is not numeric. | ||
# confidence_ellipse function stops when the conf_level is not between 0 and 1. | ||
# confidence_ellipse function returns a tibble. | ||
# confidence_ellipse function works correctly with a simple example. | ||
# confidence_ellipse function works correctly with a grouping factor. | ||
# confidence_ellipse function stops when the covariance matrix contains NA's. | ||
test_that("function stops with no data", { | ||
expect_error(confidence_ellipse(), "Missing 'data' argument.") | ||
}) | ||
test_that("function stops with non df or tbl input", { | ||
expect_error(confidence_ellipse(.data = 123), "Input 'data' must be a data frame or tibble.") | ||
}) | ||
test_that("function stops with non-numeric conf_level", { | ||
expect_error( | ||
confidence_ellipse( | ||
.data = glass, | ||
x = BaO, | ||
y = PbO, | ||
conf_level = "high"), | ||
"'conf_level' must be numeric.") | ||
}) | ||
test_that("function stops with invalid conf_level", { | ||
expect_error( | ||
confidence_ellipsoid( | ||
.data = glass, | ||
x = BaO, | ||
y = PbO, | ||
conf_level = 37), | ||
"'conf_level' must be between 0 and 1.") | ||
}) | ||
test_that("function returns a data frame or tibble", { | ||
result <- confidence_ellipse(glass, BaO, PbO) | ||
expect_true(is_tibble(result)) | ||
}) | ||
test_that("function works with simple example", { | ||
df <- data.frame(x = 1:10, y = 11:20) | ||
result <- confidence_ellipse(df, x, y) | ||
expect_true(is_tibble(result)) | ||
}) | ||
test_that("function works with grouping factor", { | ||
result <- confidence_ellipse( | ||
.data = glass, | ||
x = BaO, | ||
y = PbO, | ||
.group_by = glassType) | ||
expect_true(is_tibble(result)) | ||
}) | ||
test_that("function stops with NA's in covariance matrix", { | ||
df <- data.frame(x = 1:10, y = c(11, 2, 4, NA, 6, 3, 1, NA, NA, 10)) | ||
expect_error(confidence_ellipse(df, x, y), "Covariance matrix contains NA values.") | ||
}) | ||
|
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,63 @@ | ||
library(tibble) | ||
# Test cases covered: | ||
# confidence_ellipsoid function stops when no data is provided. | ||
# confidence_ellipsoid function stops when input data is not a data frame or tibble. | ||
# confidence_ellipsoid function stops when the conf_level is not numeric. | ||
# confidence_ellipsoid function stops when the conf_level is not between 0 and 1. | ||
# confidence_ellipsoid function returns a tibble. | ||
# confidence_ellipsoid function works correctly with a simple example. | ||
# confidence_ellipsoid function works correctly with a grouping factor. | ||
# confidence_ellipsoid function stops when the covariance matrix contains NA's. | ||
test_that("function stops with no data", { | ||
expect_error(confidence_ellipsoid(), "Missing 'data' argument.") | ||
}) | ||
test_that("function stops with non df or tbl input", { | ||
expect_error(confidence_ellipsoid(.data = 123), "Input 'data' must be a data frame or tibble.") | ||
}) | ||
test_that("function stops with non-numeric conf_level", { | ||
expect_error( | ||
confidence_ellipsoid( | ||
.data = glass, | ||
x = BaO, | ||
y = PbO, | ||
z = Na2O, | ||
conf_level = "high"), | ||
"'conf_level' must be numeric.") | ||
}) | ||
test_that("function stops with invalid conf_level", { | ||
expect_error( | ||
confidence_ellipsoid( | ||
.data = glass, | ||
x = BaO, | ||
y = PbO, | ||
z = Na2O, | ||
conf_level = 37), | ||
"'conf_level' must be between 0 and 1.") | ||
}) | ||
test_that("function returns a data frame or tibble", { | ||
result <- confidence_ellipsoid(glass, BaO, PbO, Na2O) | ||
expect_true(is_tibble(result)) | ||
}) | ||
test_that("function works with simple example", { | ||
df <- data.frame(x = 1:10, y = 11:20, z = 11:20) | ||
result <- confidence_ellipsoid(df, x, y, z) | ||
expect_true(is_tibble(result)) | ||
}) | ||
test_that("function works with grouping factor", { | ||
result <- confidence_ellipsoid( | ||
.data = glass, | ||
x = BaO, | ||
y = PbO, | ||
z = Na2O, | ||
.group_by = glassType) | ||
expect_true(is_tibble(result)) | ||
}) | ||
test_that("function stops with NA's in covariance matrix", { | ||
df <- data.frame( | ||
x = 1:10, | ||
y = c(11, 2, 4, NA, 6, 3, 1, NA, NA, 10), | ||
z = 11:20) | ||
expect_error(confidence_ellipsoid(df, x, y, z), "Covariance matrix contains NA values.") | ||
}) | ||
|
||
|