[Rprotobuf-commits] r396 - pkg/inst/unitTests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Oct 13 22:10:45 CEST 2010


Author: edd
Date: 2010-10-13 22:10:45 +0200 (Wed, 13 Oct 2010)
New Revision: 396

Modified:
   pkg/inst/unitTests/runit.addressbook.R
Log:
fixed the unit tests, albeit in a very inelegant way


Modified: pkg/inst/unitTests/runit.addressbook.R
===================================================================
--- pkg/inst/unitTests/runit.addressbook.R	2010-10-13 19:39:57 UTC (rev 395)
+++ pkg/inst/unitTests/runit.addressbook.R	2010-10-13 20:10:45 UTC (rev 396)
@@ -3,21 +3,25 @@
 ##   demo(addressbook)  ## creates 'book'
 ##   serialize(book, "/tmp/addressbook.pb")
 
-# this is executed before each test function
+# this is executed before each test function -- but somehow does not work
 .setUp <- function() {
-    #addressbook.proto.file <- system.file( "proto", "addressbook.proto", package = "RProtoBuf" )
-    #readProtoFiles( file = addressbook.proto.file )
-    file <- system.file( "examples", "addressbook.pb", package = "RProtoBuf" )
-    book <<- read( tutorial.AddressBook, file )
+    #file <- system.file( "examples", "addressbook.pb", package = "RProtoBuf" )
+    #book <- read( tutorial.AddressBook, file )
 }
 
 test.size <- function() {
+    # re-set file and book
+    file <- system.file( "examples", "addressbook.pb", package = "RProtoBuf" )
+    book <- read( tutorial.AddressBook, file )
     checkEquals(book$size("person"),        2,   msg="Number of persons")
     checkEquals(bytesize(book),             125, msg="Bytes in book")
     checkEquals(bytesize(book$person[[1]]), 60,  msg="Bytes of first person message")
 }
 
 test.personOne <- function() {
+    # re-set file and book
+    file <- system.file( "examples", "addressbook.pb", package = "RProtoBuf" )
+    book <- read( tutorial.AddressBook, file )
     checkEquals(book$person[[1]]$name,              "Romain Francois",   msg="First person name")
     checkEquals(book$person[[2]]$name,              "Dirk Eddelbuettel", msg="First person name")
     checkEquals(book$person[[1]]$id,                1,   		 msg="First person id")



More information about the Rprotobuf-commits mailing list