Skip to content

Commit 33c98d3

Browse files
committed
tinytest step seventeen: system and table
1 parent 99ea11e commit 33c98d3

File tree

6 files changed

+85
-93
lines changed

6 files changed

+85
-93
lines changed

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
* inst/tinytest/test_sugar.R: Idem
3939
* inst/tinytest/test_sugar_var.R: Idem
4040
* inst/tinytest/test_support.R: Idem
41+
* inst/tinytest/test_system.R: Idem
42+
* inst/tinytest/test_table.R: Idem
4143

4244
2019-11-23 Dirk Eddelbuettel <edd@debian.org>
4345

inst/tinytest/test_system.R

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
## Copyright (C) 2016 - 2019 Dirk Eddelbuettel
3+
##
4+
## This file is part of Rcpp.
5+
##
6+
## Rcpp is free software: you can redistribute it and/or modify it
7+
## under the terms of the GNU General Public License as published by
8+
## the Free Software Foundation, either version 2 of the License, or
9+
## (at your option) any later version.
10+
##
11+
## Rcpp is distributed in the hope that it will be useful, but
12+
## WITHOUT ANY WARRANTY; without even the implied warranty of
13+
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
## GNU General Public License for more details.
15+
##
16+
## You should have received a copy of the GNU General Public License
17+
## along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
18+
19+
.runThisTest <- Sys.getenv("RunAllRcppTests") == "yes"
20+
21+
if (!.runThisTest) exit_file("Skipping, set 'RunAllRcppTests=yes' to run.")
22+
23+
library(Rcpp)
24+
25+
# test.Rcpp.system.file <- function() {
26+
inc_rcpp <- Rcpp:::Rcpp.system.file("include")
27+
inc_sys <- tools::file_path_as_absolute( base::system.file("include", package = "Rcpp"))
28+
expect_equal(inc_rcpp, inc_sys, info = "Rcpp.system.file")
29+
30+
# test.RcppLd <- function() {
31+
expect_true(Rcpp:::RcppLdPath() == "", info = "RcppLdPath")
32+
expect_true(Rcpp:::RcppLdFlags() == "", info = "RcppLdFlags")
33+
expect_equal(Rcpp:::LdFlags(), NULL, info = "LdFlags")
34+
35+
# test.RcppCxx <- function() {
36+
expect_true(Rcpp:::canUseCXX0X(), info = "canUseCXX0X")
37+
expect_true(Rcpp:::RcppCxxFlags() != "", info = "RcppCxxFlags()")
38+
# -- side effect of print expect_null(Rcpp:::CxxFlags(), info = "CxxFlags()")
39+
40+
expect_true(length(Rcpp:::RcppCapabilities()) >= 13, info = "RcppCapabilities()")

inst/tinytest/test_table.R

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
## Copyright (C) 2014 - 2019 Dirk Eddelbuettel, Romain Francois, and Kevin Ushey
3+
##
4+
## This file is part of Rcpp.
5+
##
6+
## Rcpp is free software: you can redistribute it and/or modify it
7+
## under the terms of the GNU General Public License as published by
8+
## the Free Software Foundation, either version 2 of the License, or
9+
## (at your option) any later version.
10+
##
11+
## Rcpp is distributed in the hope that it will be useful, but
12+
## WITHOUT ANY WARRANTY; without even the implied warranty of
13+
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
## GNU General Public License for more details.
15+
##
16+
## You should have received a copy of the GNU General Public License
17+
## along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
18+
19+
.runThisTest <- Sys.getenv("RunAllRcppTests") == "yes"
20+
21+
if (!.runThisTest) exit_file("Skipping, set 'RunAllRcppTests=yes' to run.")
22+
23+
library(Rcpp)
24+
sourceCpp("cpp/table.cpp")
25+
26+
27+
table_ <- function(x) c(base::table(x, useNA="ifany"))
28+
29+
# test.table.numeric <- function() {
30+
x <- c(1, 2, 1, 1, NA, NaN, -Inf, Inf)
31+
expect_equal( RcppTable(x), table_(x), info = "table matches R: numeric case")
32+
33+
# test.table.integer <- function() {
34+
x <- c(-1L, 1L, NA_integer_, NA_integer_, 100L, 1L)
35+
expect_equal( RcppTable(x), table_(x), info = "table matches R: integer case")
36+
37+
# test.table.logical <- function() {
38+
x <- c(TRUE, TRUE, FALSE, NA)
39+
expect_equal( RcppTable(x), table_(x), info = "table matches R: logical case")
40+
41+
# test.table.character <- function() {
42+
x <- c("a", "a", "b", "a", NA, NA)
43+
expect_equal( RcppTable(x), table_(x), info = "table matches R: character case")

inst/unitTests/runit.system.R

Lines changed: 0 additions & 45 deletions
This file was deleted.

inst/unitTests/runit.table.R

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)