[Rprotobuf-commits] r464 - in pkg: . R inst inst/unitTests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Aug 9 04:03:14 CEST 2012
Author: edd
Date: 2012-08-09 04:03:14 +0200 (Thu, 09 Aug 2012)
New Revision: 464
Added:
pkg/inst/unitTests/runit.serialize.R
Modified:
pkg/ChangeLog
pkg/DESCRIPTION
pkg/R/serialize.R
pkg/inst/NEWS.Rd
Log:
another patch by Murray, and moving this towards 0.2.5 release
Modified: pkg/ChangeLog
===================================================================
--- pkg/ChangeLog 2012-08-09 01:51:29 UTC (rev 463)
+++ pkg/ChangeLog 2012-08-09 02:03:14 UTC (rev 464)
@@ -7,10 +7,16 @@
* inst/unitTests/runit.nested.R: Added test from Murray
* inst/unitTests/data/nested.proto: Nested protbuf def from Murray
+ * R/serialize.R: Added patch by Murray to not serialize uninitalized
+ protocol buffers (with missing required fields)
+ * inst/unitTests/runit.serialize.R: Added tests for this
+
* inst/NEWS.Rd: Converted NEWS file to .Rd format
- * DESCRIPTION: changed Maintainer: to single person per CRAN Policy
-
+ * DESCRIPTION: Changed Maintainer: to single person per CRAN Policy
+
+ * vignettes/: Moved from inst/doc/ per CRAN Policy
+
2012-05-15 Dirk Eddelbuettel <edd at debian.org>
* DESCRIPTION: Release 0.2.4
Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION 2012-08-09 01:51:29 UTC (rev 463)
+++ pkg/DESCRIPTION 2012-08-09 02:03:14 UTC (rev 464)
@@ -1,5 +1,5 @@
Package: RProtoBuf
-Version: 0.2.4.1
+Version: 0.2.5
Date: $Date$
Author: Romain Francois <romain at r-enthusiasts.com> and Dirk Eddelbuettel <edd at debian.org>
Maintainer: Dirk Eddelbuettel <edd at debian.org>
Modified: pkg/R/serialize.R
===================================================================
--- pkg/R/serialize.R 2012-08-09 01:51:29 UTC (rev 463)
+++ pkg/R/serialize.R 2012-08-09 02:03:14 UTC (rev 464)
@@ -7,7 +7,7 @@
setGeneric( "serialize" )
setMethod( "serialize", c( object = "Message" ) ,
function( object, connection, ascii = FALSE, refhook = NULL){
-
+ stopifnot(object$isInitialized())
iscon <- inherits(connection, "connection")
isnull <- is.null( connection )
@@ -42,4 +42,3 @@
}
}
)
-
Modified: pkg/inst/NEWS.Rd
===================================================================
--- pkg/inst/NEWS.Rd 2012-08-09 01:51:29 UTC (rev 463)
+++ pkg/inst/NEWS.Rd 2012-08-09 02:03:14 UTC (rev 464)
@@ -4,8 +4,14 @@
\section{Changes in version 0.2.5 (2012-08-08)}{
\itemize{
- \item Applied patch by Murray to correctly deal with nested Protocol
- Buffer definitions, and also added new unit test for this
+ \item Applied patches by Murray to
+ \itemize{
+ \item correctly deal with nested Protocol Buffer definitions, and
+ also add new unit test for this
+ \item test a a protocol buffer for missing required fields before
+ serializing it, also add a unit test
+ }
+ \item Moved inst/doc/ to vignettes/ per newer CRAN Policy
}
}
\section{Changes in version 0.2.4 (2012-05-15)}{
Added: pkg/inst/unitTests/runit.serialize.R
===================================================================
--- pkg/inst/unitTests/runit.serialize.R (rev 0)
+++ pkg/inst/unitTests/runit.serialize.R 2012-08-09 02:03:14 UTC (rev 464)
@@ -0,0 +1,41 @@
+# Copyright 2012 Google Inc. All Rights Reserved.
+# Author: Murray Stokely
+#
+# 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.
+
+
+# this is executed before each test function
+.setUp <- function(){
+ if( !exists("tutorial.Person", "RProtoBuf:DescriptorPool") ) {
+ unitest.proto.file <- system.file("proto", "addressbook.proto",
+ package = "RProtoBuf" )
+ readProtoFiles(file = unitest.proto.file)
+ }
+}
+
+test.serialize <- function() {
+ person <- new(tutorial.Person)
+
+ checkTrue(!person$isInitialized())
+ checkException(serialize(person, NULL),
+ "Uninitialized object should fail to serialize.")
+ person$id <- 1
+ checkException(serialize(person, NULL),
+ "Uninitialized object should fail to serialize.")
+ person$name <- "Murray"
+
+ checkTrue(person$isInitialized())
+ checkTrue(length(serialize(person, NULL)) > 1)
+}
More information about the Rprotobuf-commits
mailing list