aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2019-02-22 20:51:13 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2019-02-22 20:51:13 +0100
commitdd6c4a8f895fd470345e7ae773299daaa4de7aef (patch)
tree03ee92fe3280f126ba7a2a21af2fec190458ccb9 /tests
parentf12b9bcc5bded392eee51810fac5f94c2ae7d9c2 (diff)
Implement the NAFTA evaluation scheme
Diffstat (limited to 'tests')
-rw-r--r--tests/testthat/test_nafta.R41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/testthat/test_nafta.R b/tests/testthat/test_nafta.R
new file mode 100644
index 00000000..7d650ad8
--- /dev/null
+++ b/tests/testthat/test_nafta.R
@@ -0,0 +1,41 @@
+# Copyright (C) 2019 Johannes Ranke
+# Contact: jranke@uni-bremen.de
+
+# This file is part of the R package mkin
+
+# mkin is free software: you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation, either version 3 of the License, or (at your option) any later
+# version.
+
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+
+# You should have received a copy of the GNU General Public License along with
+# this program. If not, see <http://www.gnu.org/licenses/>
+
+library(testthat)
+library(mkin)
+
+context("Evaluations according to the NAFTA guidance from 2015")
+
+test_that("Data for more than one compound are rejected",
+ expect_error(nafta(FOCUS_2006_D)))
+
+test_that("Test data from Appendix D are correctly evaluated", {
+ expect_message(res <- nafta(MRID_555555, "MRID 555555"))
+
+ # From Figure D.1
+ dtx_sop <- matrix(c(407, 541, 429, 1352, 5192066, 2383), nrow = 3, ncol = 2)
+ expect_equivalent(res$distimes[, 1:2], dtx_sop, tolerance = 1,
+ scale = 1)
+ C0_sop <- c(SFO = 83.8, IORE = 96.9, DFOP = 97.6)
+ C0_mkin <- sapply(res$parameters, function(x) x["parent_0", "Estimate"])
+ expect_equivalent(C0_mkin, C0_sop, scale = 1, tolerance = 0.1)
+
+ expect_equal(round(res$S_c), 717)
+ expect_equal(signif(res$S[["SFO"]], 3), 1.38e+3)
+ expect_equal(round(res$t_rep), 841)
+})

Contact - Imprint