Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip comparison of a field if it's unset in both messages #57

Merged
merged 1 commit into from Dec 1, 2018

Conversation

Projects
None yet
2 participants
@jarodmeng
Copy link
Contributor

commented Dec 1, 2018

This fixes #56.

library(RProtoBuf)

# Create an example proto file with recursive field
proto.file <- tempfile(fileext = ".proto")
writeLines(
  "
  syntax = 'proto2';

  package example;

  message Recursion {
      optional int32 id = 1;
      optional Recursion value = 2;
  }
  ", proto.file
)
readProtoFiles(proto.file)

# Create two identical proto messages with recursive field unset
p <- new(example.Recursion, id = 1)
p2 <- new(example.Recursion, id = 1)
# Create a different proto message
p3 <- new(example.Recursion, id = 2)

# identical() and all.equal() now work even for recursive fields
identical(p, p2)
#> [1] TRUE
all.equal(p, p2)
#> [1] TRUE

identical(p, p3)
#> [1] FALSE
all.equal(p, p3)
#> [1] FALSE

Created on 2018-11-30 by the reprex package (v0.2.1)

@eddelbuettel eddelbuettel merged commit 563ba0c into eddelbuettel:master Dec 1, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.