testthat::expect_equal
passes even when two Message objects have totally different content (see reprex below).
expect_equal()
calls the generic all.equal()
to compare two objects. Instead of dispatching on the S4 method defined in RProtoBuf, all.equal()
(when called from testthat
) actually dispatch to the default all.equal.default()
which in turn uses attr.all.equal()
to only compare the attributes of the two objects.
This is likely because RProtoBuf doesn't define an S3method for all.equal
as the manual suggests. A simple addition to the NAMESPACE
file should fix the issue. Happy to send in a PR on this if necessary.
library(RProtoBuf) library(testthat) # Create two obviously different messages from the same descriptor p <- new(tutorial.Person, name = "John", id = 1) p2 <- new(tutorial.Person, name = "Doe", id = 2) # Directly calling all.equal() returns the correct result all.equal(p, p2) #> [1] FALSE # Calling all.equal.default() returns the wrong result all.equal.default(p, p2) #> [1] TRUE # testthat::expect_equal() is calling the wrong method and returns a spurious # pass expect_equal(p, p2)
Created on 2018-11-26 by the reprex package (v0.2.1)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4