[Rprotobuf-commits] r432 - in pkg/inst/unitTests: . data

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Nov 7 15:08:38 CET 2011


Author: romain
Date: 2011-11-07 15:08:38 +0100 (Mon, 07 Nov 2011)
New Revision: 432

Added:
   pkg/inst/unitTests/data/int64.proto
   pkg/inst/unitTests/runit.int64.support.R
Log:
testing int64 support in message fields

Added: pkg/inst/unitTests/data/int64.proto
===================================================================
--- pkg/inst/unitTests/data/int64.proto	                        (rev 0)
+++ pkg/inst/unitTests/data/int64.proto	2011-11-07 14:08:38 UTC (rev 432)
@@ -0,0 +1,7 @@
+
+message TestInt64 {
+  required int64 a = 1;
+  required uint64 b = 2;
+  repeated int64 c = 3 ;
+  repeated uint64 d = 4 ;
+}

Added: pkg/inst/unitTests/runit.int64.support.R
===================================================================
--- pkg/inst/unitTests/runit.int64.support.R	                        (rev 0)
+++ pkg/inst/unitTests/runit.int64.support.R	2011-11-07 14:08:38 UTC (rev 432)
@@ -0,0 +1,31 @@
+# Copyright 2011 Google Inc.
+# Copyright 2011 Dirk Eddelbuettel and Romain Francois 
+#
+# This program 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.
+# 
+# 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, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+.setUp <- function(){
+    if( ! exists( "TestInt64", "RProtoBuf:DescriptorPool" ) ){
+        unitest.proto.file <- system.file( "unitTests", "data", "int64.proto", package = "RProtoBuf" )
+        readProtoFiles(file = unitest.proto.file)
+    }
+}
+
+test.int64 <- function() {
+  msg <- new( TestInt64, a = 1, b = 2, c = 1:4, d = 1:4 )
+  checkEquals( msg$a, as.int64(1) )
+  checkEquals( msg$b, as.uint64(2) )
+  checkEquals( msg$c, as.int64(1:4) )
+  checkEquals( msg$d, as.uint64(1:4) )
+}



More information about the Rprotobuf-commits mailing list