[Rcpp-commits] r4240 - in pkg/Rcpp: . inst/unitTests inst/unitTests/cpp
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Feb 4 17:47:39 CET 2013
Author: romain
Date: 2013-02-04 17:47:39 +0100 (Mon, 04 Feb 2013)
New Revision: 4240
Added:
pkg/Rcpp/inst/unitTests/cpp/wstring.cpp
pkg/Rcpp/inst/unitTests/runit.wstring.R
Modified:
pkg/Rcpp/ChangeLog
Log:
added unit tests for wstring support
Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog 2013-02-04 15:54:58 UTC (rev 4239)
+++ pkg/Rcpp/ChangeLog 2013-02-04 16:47:39 UTC (rev 4240)
@@ -11,6 +11,8 @@
* include/Rcpp/traits/char_type.h : new trait to help the wstring support
* include/Rcpp/String.h : added some support for wstring
* include/Rcpp/vector/string_proxy.h : adapt to add wstring support
+ * unitTests/runit.wstring.R : unit tests for wstring support
+ * unitTests/cpp/wstring.cpp : unit tests for wstring support
2013-02-03 Romain Francois <romain at r-enthusiasts.com>
Added: pkg/Rcpp/inst/unitTests/cpp/wstring.cpp
===================================================================
--- pkg/Rcpp/inst/unitTests/cpp/wstring.cpp (rev 0)
+++ pkg/Rcpp/inst/unitTests/cpp/wstring.cpp 2013-02-04 16:47:39 UTC (rev 4240)
@@ -0,0 +1,27 @@
+#include <Rcpp.h>
+using namespace Rcpp ;
+
+// [[Rcpp::export]]
+CharacterVector CharacterVector_wstring( ){
+ CharacterVector res(2) ;
+ res[0] = L"foo" ;
+ res[0] += L"bar" ;
+
+ res[1] = std::wstring( L"foo" ) ;
+ res[1] += std::wstring( L"bar" ) ;
+
+ return res ;
+}
+
+// [[Rcpp::export]]
+std::wstring wstring_return(){
+ return L"foo" ;
+}
+
+// [[Rcpp::export]]
+String wstring_param(const std::wstring& s1, const std::wstring& s2){
+ String s = s1 ;
+ s += s2 ;
+ return s ;
+}
+
Added: pkg/Rcpp/inst/unitTests/runit.wstring.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.wstring.R (rev 0)
+++ pkg/Rcpp/inst/unitTests/runit.wstring.R 2013-02-04 16:47:39 UTC (rev 4240)
@@ -0,0 +1,43 @@
+#!/usr/bin/r -t
+# -*- mode: R; tab-width: 4; -*-
+#
+# Copyright (C) 2013 Dirk Eddelbuettel and Romain Francois
+# Copyright (C) 2013 Rice University
+#
+# This file is part of Rcpp.
+#
+# Rcpp 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 2 of the License, or
+# (at your option) any later version.
+#
+# Rcpp 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 Rcpp. If not, see <http://www.gnu.org/licenses/>.
+
+.runThisTest <- Sys.getenv("RunAllRcppTests") == "yes"
+
+if (.runThisTest) {
+
+.setUp <- function(){
+ sourceCpp(file.path(pathRcppTests, "cpp/wstring.cpp"))
+}
+
+test.CharacterVector_wstring <- function(){
+ res <- CharacterVector_wstring()
+ checkEquals( res, c("foobar", "foobar" ) )
+}
+
+test.wstring_return <- function(){
+ checkEquals( wstring_return(), "foo" )
+}
+
+test.wstring_param <- function(){
+ checkEquals( wstring_param( "foo", "bar" ), "foobar" )
+}
+
+}
More information about the Rcpp-commits
mailing list