-
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.
Merge pull request #20 from KWB-R/add-tests
Add tests
- Loading branch information
Showing
49 changed files
with
528 additions
and
554 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,5 @@ | ||
test_that("functions are missing", { | ||
|
||
expect_error(r2q:::import_hydrology_data) | ||
|
||
}) |
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 |
---|---|---|
@@ -1,17 +1,29 @@ | ||
# | ||
# This test file has been generated by kwb.test::create_test_files() | ||
# launched by user hsonne on 2023-07-14 11:50:24. | ||
# Your are strongly encouraged to modify the dummy functions | ||
# so that real cases are tested. You should then delete this comment. | ||
# | ||
|
||
test_that("Input_event() works", { | ||
|
||
f <- r2q:::Input_event | ||
f <- r2q::Input_event | ||
|
||
expect_error( | ||
r2q:::Input_event() | ||
# argument "area_runoff" is missing, with no default | ||
) | ||
expect_error(f()) | ||
|
||
expect_identical( | ||
f( | ||
area_runoff = 0, | ||
Ci_storm = 0, | ||
coeff_runoff = 0, | ||
q_rain = 0, | ||
t_rain = 0 | ||
), | ||
0 | ||
) | ||
|
||
expect_identical( | ||
f( | ||
area_runoff = 1000, | ||
Ci_storm = 1, | ||
coeff_runoff = 1, | ||
q_rain = 1, | ||
t_rain = 1 | ||
), | ||
1 | ||
) | ||
|
||
}) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,17 +1,12 @@ | ||
# | ||
# This test file has been generated by kwb.test::create_test_files() | ||
# launched by user hsonne on 2023-07-14 11:50:24. | ||
# Your are strongly encouraged to modify the dummy functions | ||
# so that real cases are tested. You should then delete this comment. | ||
# | ||
|
||
test_that("area_from_load() works", { | ||
|
||
f <- r2q:::area_from_load | ||
|
||
expect_error( | ||
r2q:::area_from_load() | ||
# argument "load_runoff" is missing, with no default | ||
) | ||
expect_error(f()) | ||
|
||
expect_identical( | ||
f(load_runoff = 1, Ci_storm = 1, coeff_runoff = 1, q_rain = 1, t_rain = 1), | ||
1000 | ||
) | ||
|
||
}) |
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 |
---|---|---|
@@ -1,17 +1,50 @@ | ||
# | ||
# This test file has been generated by kwb.test::create_test_files() | ||
# launched by user hsonne on 2023-07-14 11:50:22. | ||
# Your are strongly encouraged to modify the dummy functions | ||
# so that real cases are tested. You should then delete this comment. | ||
# | ||
|
||
test_that("assess_all_hazards() works", { | ||
|
||
f <- r2q:::assess_all_hazards | ||
f <- r2q::assess_all_hazards | ||
|
||
expect_error( | ||
r2q:::assess_all_hazards() | ||
# argument "hazard_list" is missing, with no default | ||
) | ||
expect_error(f()) | ||
|
||
hazard_list <- list( | ||
x = c(pot_med = 1, pot_q95 = 2), | ||
y = c(pot_med = 3, pot_q95 = 4) | ||
) | ||
|
||
site_data <- list( | ||
area_urban_connected = list(Value = 1), | ||
area_urban_connectable = list(Value = 1), | ||
area_plan = list(Value = 1), | ||
area_urban = list(Value = 1), | ||
f_D_is = list(Value = 1), | ||
f_D_pot = list(Value = 1), | ||
Q_event = list(Value = 1), | ||
river_length = list(Value = 100), | ||
cross_section_event = list(Value = 100) | ||
) | ||
|
||
c_table <- data.frame( | ||
substance = c("x", "y"), | ||
threshold_type = c("acute", "annual"), | ||
threshold = c(0.1, 0.2), | ||
unit = c("ng", "mg"), | ||
pot_med = c(1, 2), | ||
is_med = c(1, 2), | ||
is_q95 = c(3, 4), | ||
c_river = c(1, 2) | ||
) | ||
|
||
expect_error(result <- f( | ||
hazard_list = hazard_list, | ||
site_data = site_data, | ||
c_table = c_table, | ||
q_rain = 1, | ||
t_rain = 1 | ||
)) | ||
|
||
# expect_is(result, "list") | ||
# | ||
# expect_identical(names(result), c( | ||
# "general", | ||
# "planning_pot", | ||
# "planning_scaled" | ||
# )) | ||
}) |
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
tests/testthat/test-function-calculate_relevant_discharge.R
This file was deleted.
Oops, something went wrong.
22 changes: 11 additions & 11 deletions
22
tests/testthat/test-function-calculate_tolerable_discharge.R
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 |
---|---|---|
@@ -1,15 +1,15 @@ | ||
# | ||
# This test file has been generated by kwb.test::create_test_files() | ||
# launched by user mzamzo on 2021-11-03 11:55:01. | ||
# Your are strongly encouraged to modify the dummy functions | ||
# so that real cases are tested. You should then delete this comment. | ||
# | ||
|
||
test_that("calculate_tolerable_discharge() works", { | ||
|
||
expect_error( | ||
r2q:::calculate_tolerable_discharge(site_data = NA) | ||
# '' does not exist in current working directory ('C:/Users/mzamzo/Documents/R/git/r2q'). | ||
) | ||
f <- r2q::calculate_tolerable_discharge | ||
|
||
check <- function(result) { | ||
expect_s3_class(result, "data.frame") | ||
expect_identical(nrow(result), 1L) | ||
} | ||
|
||
expect_output(result <- f(verbose = TRUE)) | ||
check(result) | ||
|
||
expect_silent(result <- f(verbose = FALSE)) | ||
check(result) | ||
}) |
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 |
---|---|---|
@@ -1,17 +1,8 @@ | ||
# | ||
# This test file has been generated by kwb.test::create_test_files() | ||
# launched by user hsonne on 2023-07-14 11:50:22. | ||
# Your are strongly encouraged to modify the dummy functions | ||
# so that real cases are tested. You should then delete this comment. | ||
# | ||
|
||
test_that("check_all_substances() works", { | ||
|
||
f <- r2q:::check_all_substances | ||
|
||
expect_error( | ||
r2q:::check_all_substances() | ||
# argument "c_table" is missing, with no default | ||
) | ||
|
||
expect_error(f()) | ||
expect_type(f(c_table = data.frame(), c_type = "average"), "list") | ||
expect_type(f(c_table = data.frame(), c_type = "worstcase"), "list") | ||
}) |
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 |
---|---|---|
@@ -1,17 +1,10 @@ | ||
# | ||
# This test file has been generated by kwb.test::create_test_files() | ||
# launched by user hsonne on 2023-07-14 11:50:23. | ||
# Your are strongly encouraged to modify the dummy functions | ||
# so that real cases are tested. You should then delete this comment. | ||
# | ||
|
||
test_that("check_pollutant_impact() works", { | ||
|
||
f <- r2q:::check_pollutant_impact | ||
f <- r2q::check_pollutant_impact | ||
|
||
expect_error( | ||
r2q:::check_pollutant_impact() | ||
# argument "Ci_river" is missing, with no default | ||
) | ||
expect_error(f()) | ||
|
||
expect_identical(-Inf, f(Ci_river = 1, Ci_threshold = 0, Ci_storm = 1)) | ||
expect_identical(Inf, f(Ci_river = 1, Ci_threshold = 1, Ci_storm = 1)) | ||
expect_true(f(Ci_river = 1, Ci_threshold = 1, Ci_storm = 2)) | ||
}) |
48 changes: 36 additions & 12 deletions
48
tests/testthat/test-function-combine_concentration_tables.R
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 |
---|---|---|
@@ -1,16 +1,40 @@ | ||
# | ||
# This test file has been generated by kwb.test::create_test_files() | ||
# launched by user mzamzo on 2021-11-03 11:55:01. | ||
# Your are strongly encouraged to modify the dummy functions | ||
# so that real cases are tested. You should then delete this comment. | ||
# | ||
|
||
test_that("combine_concentration_tables() works", { | ||
|
||
expect_error( | ||
r2q:::combine_concentration_tables() | ||
# argument "threshold_table" is missing, with no default | ||
) | ||
f <- r2q::combine_concentration_tables | ||
|
||
expect_error(f()) | ||
|
||
threshold_table <- data.frame( | ||
substance = "a", | ||
Unit = "b", | ||
threshold = 1, | ||
threshold_type = "c" | ||
) | ||
|
||
storm_table <- data.frame( | ||
substance = "a", | ||
unit = "b", | ||
x = 1 | ||
) | ||
|
||
background_table <- data.frame( | ||
substance = "a", | ||
unit = "b", | ||
y = 2 | ||
) | ||
|
||
result <- f( | ||
threshold_table = threshold_table, | ||
storm_table = storm_table, | ||
background_table = background_table | ||
) | ||
|
||
expect_identical(result, data.frame( | ||
substance = "a", | ||
unit = "b", | ||
threshold = 1, | ||
threshold_type = "c", | ||
c_river = 2, | ||
x = 1 | ||
)) | ||
}) | ||
|
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,13 +1,11 @@ | ||
# | ||
# This test file has been generated by kwb.test::create_test_files() | ||
# launched by user mzamzo on 2021-11-03 11:55:01. | ||
# Your are strongly encouraged to modify the dummy functions | ||
# so that real cases are tested. You should then delete this comment. | ||
# | ||
|
||
test_that("get_Hq1_pnat() works", { | ||
|
||
r2q:::get_Hq1_pnat(slope = 0.1, area_catch = 1) | ||
|
||
f <- r2q:::get_Hq1_pnat | ||
|
||
expect_identical(f(slope = 0.1, area_catch = 60), 50) | ||
expect_identical(f(slope = 0.1, area_catch = 3), 126) | ||
expect_identical(f(slope = 0.5, area_catch = 100), 100) | ||
expect_identical(f(slope = 0.5, area_catch = 99), 101) | ||
expect_identical(f(slope = 2, area_catch = 400), 150) | ||
expect_identical(f(slope = 2, area_catch = 300), 200) | ||
}) | ||
|
Oops, something went wrong.