forked from flr/ss3om_old
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtestthat.R
34 lines (26 loc) · 856 Bytes
/
testthat.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# testthat.R - DESC
# /testthat.R
# Copyright 2015 Iago Mosqueira (EC JRC) <[email protected]>
#
# Distributed under terms of the European Union Public Licence (EUPL) 1.1.
#
# Notes:
library(testthat)
library(ss3om)
# expect_comparable {{{
expect_comparable <- function(object, expected, ..., label = NULL,
expected.label = NULL, diff = 0.05) {
# 1. Capture object and label
act <- quasi_label(rlang::enquo(object), label, arg = "object")
exp <- quasi_label(rlang::enquo(expected), expected.label, arg = "expected")
# 2. Call expect()
act$diff <- c((object - expected) / abs(expected))
expect(
all(abs(act$diff) < diff),
sprintf("some relative differences larger than %.2f%%, mean = %.2f",
diff * 100, mean(act$diff))
)
# 3. Invisibly return the value
invisible(act$diff)
} # }}}
test_check("ss3om")