Skip to content

Commit 41b11e2

Browse files
committed
adding a simple test helper set up a few weeks ago
defaults to FALSE, doing no harm
1 parent 9231d08 commit 41b11e2

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

inst/unitTests/runit.quickanddirty.R

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env r
2+
# -*- mode: R; ess-indent-level: 4; tab-width: 4; indent-tabs-mode: nil; -*
3+
#
4+
# Copyright (C) 2012 - 2016 Dirk Eddelbuettel and Romain Francois
5+
#
6+
# This file is part of Rcpp.
7+
#
8+
# Rcpp is free software: you can redistribute it and/or modify it
9+
# under the terms of the GNU General Public License as published by
10+
# the Free Software Foundation, either version 2 of the License, or
11+
# (at your option) any later version.
12+
#
13+
# Rcpp is distributed in the hope that it will be useful, but
14+
# WITHOUT ANY WARRANTY; without even the implied warranty of
15+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
# GNU General Public License for more details.
17+
#
18+
# You should have received a copy of the GNU General Public License
19+
# along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
20+
21+
.runThisTest <- Sys.getenv("RunAllRcppTests") == "yes"
22+
23+
if (FALSE && .runThisTest) {
24+
25+
#.setUp <- Rcpp:::unitTestSetup("rmath.cpp")
26+
sourceCpp("cpp/rmath.cpp")
27+
28+
test.rmath.norm <- function() {
29+
x <- 0.25
30+
a <- 1.25
31+
b <- 2.50
32+
checkEquals(runit_dnorm(x, a, b),
33+
c(dnorm(x, a, b, log=FALSE), dnorm(x, a, b, log=TRUE)),
34+
msg = " rmath.dnorm")
35+
36+
checkEquals(runit_pnorm(x, a, b),
37+
c(pnorm(x, a, b, lower=TRUE, log=FALSE), pnorm(log(x), a, b, lower=TRUE, log=TRUE),
38+
pnorm(x, a, b, lower=FALSE, log=FALSE), pnorm(log(x), a, b, lower=FALSE, log=TRUE)),
39+
msg = " rmath.pnorm")
40+
41+
checkEquals(runit_qnorm(x, a, b),
42+
c(qnorm(x, a, b, lower=TRUE, log=FALSE), qnorm(log(x), a, b, lower=TRUE, log=TRUE),
43+
qnorm(x, a, b, lower=FALSE, log=FALSE), qnorm(log(x), a, b, lower=FALSE, log=TRUE)),
44+
msg = " rmath.qnorm")
45+
46+
set.seed(333)
47+
rcpp_result <- runit_rnorm(a, b)
48+
set.seed(333)
49+
rcpp_result_sugar <- runit_rnorm_sugar(a, b)
50+
set.seed(333)
51+
r_result <- rnorm(5, a, b)
52+
53+
checkEquals(rcpp_result, r_result, msg = " rmath.rnorm")
54+
checkEquals(rcpp_result_sugar, r_result, msg = " rmath.rnorm.sugar")
55+
}
56+
57+
}
58+
59+
60+

0 commit comments

Comments
 (0)