forked from quantargo/datacleaner
-
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.
Tests for all functions in the package are added.
- Loading branch information
1 parent
61e0532
commit c3d79c6
Showing
6 changed files
with
34 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
test_that("Incorrect input of meanimpute", { | ||
#tests related to input vector | ||
expect_error(meanimpute(NULL),"Input vector cannot be NULL.") | ||
expect_error(meanimpute(c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA)),"Input vector should contain at least one numeric element.") | ||
expect_error(meanimpute(c(1,2,3,4,"Dracula"), "Input vector should contain at least one numeric element.")) | ||
|
||
}) |
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,8 @@ | ||
test_that("Input of transform_log() is correct.", { | ||
#tests related to input vector | ||
expect_error(transform_log(NULL), "Input vector is not allowed to be NULL.") | ||
expect_error(transform_log(c(NA,NA,NA,6,NA,5,NA,NA,7,NA,NA)), "There is at least one NA value in input vector.") | ||
expect_error(transform_log(c(1,2,3,4,5,6,7,8,"string",1000)), "There is at least one non-numeric value.") | ||
expect_error(transform_log(c(1,2,3,4,5,6,7,8,-5)), "There is at least one negative value.") | ||
|
||
}) |
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,10 @@ | ||
test_that("Incorrect input", { | ||
#tests related to input vector | ||
expect_error(windsorize(NULL, .9), "Input vector cannot be NULL.") | ||
expect_error(windsorize(c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA), .9), "There should be no NA's in input vector.") | ||
expect_error(windsorize(c(-1000,1,2,3,4,5,6,7,8,"string",1000), .9), "There should only numeric values in the input vector.") | ||
expect_error(windsorize(c(-1000,1,2,3,4,6,7,8,9,1000), "string"), "Input quantile should be a number between 0 and 1.") | ||
expect_error(windsorize(c(-1000,1,2,3,4,6,7,8,9,1000), 2), "Input quantile should be a number between 0 and 1") | ||
expect_error(windsorize(c(-1000,1,2,3,4,6,7,8,9,1000), -2), "Input quantile should be a number between 0 and 1") | ||
|
||
}) |
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 @@ | ||
test_that("NA's in vector are correctly replace by mean", { | ||
expect_equal(meanimpute(c(2,4,6,NA)), c(2,4,6,4)) | ||
}) |
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 @@ | ||
test_that("Vector is correctly log-transformed", { | ||
expect_equal(transform_log(c(1,1,1)), c(0,0,0)) | ||
}) |
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 @@ | ||
test_that("vector is correctly windsorized", { | ||
expect_equal(windsorize(c(-1000,1,2,3,4,5,6,7,8,9,1000),0.9), c(-499.5,1,2,3,4,5,6,7,8,9,504.5) ) | ||
}) |