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

How to use EqualsProto to check protobuf? #1761

Open
yangminzhu opened this issue Aug 21, 2018 · 20 comments
Open

How to use EqualsProto to check protobuf? #1761

yangminzhu opened this issue Aug 21, 2018 · 20 comments
Assignees

Comments

@yangminzhu
Copy link

The advanced doc says you can use gMock's EqualsProto to compare protos in your tests, but I find the EqualsProto is not defined inside gMock but in the nucleus repo that is used for parsing common genomics file.

I don't want to depend on this nucleus repo, so how can I use the EqualsProto in my project?

Thanks

@gennadiycivil
Copy link
Contributor

@yangminzhu Thank you for noticing. The docs are not completely synced / cleanup yet. It is possible that you are seeing reference to internal-only feature

@yangminzhu
Copy link
Author

I don't know if this is supposed to be an internal-only feature, I found it from the public doc: https://github.com/google/googletest/blob/master/googletest/docs/advanced.md#asserting-using-gmock-matchers and the source code is uploaded to https://github.com/google/nucleus/blob/master/nucleus/testing/protocol-buffer-matchers.h.

@devjgm
Copy link
Contributor

devjgm commented Jun 24, 2019

What's the status of this issue? The advanced.md file references using ::testing::EqualsProto, but this matcher is not part of gmock.

@neuromage
Copy link

Hi,

Do we have any plans to move and OSS protocol-buffer-matchers.h to googletest?

@smolkaj
Copy link

smolkaj commented May 6, 2020

Any updates on this? Not having this be open source complicates open sourcing google projects.

@dayfine
Copy link

dayfine commented Jul 1, 2020

Is there a timeline on this (Suppose it's still on the roadmap)? I suppose it might not be as simple as copying over the two files in the necleus repo as I'd imagine the export need to be (somewhat) consistency with the current internal version?

@jheaff1
Copy link

jheaff1 commented Jul 1, 2020

I too am interested in this

@mr-salty
Copy link

mr-salty commented Aug 4, 2020

+1 this would be very useful to the Cloud C++ team. We have made do so far with our own hand-crafted matchers but having the full suite of proto-matchers would be nicer (and we can delete our own implementations).

@blais
Copy link

blais commented Dec 24, 2020

I could have used this too today. Please!

@buptsb
Copy link

buptsb commented Jan 17, 2021

protocol-buffer-matchers.h in Nucleus is heavily integrated with TensorFlow, it's not easy to include it without a rewrite.

@inazarenko
Copy link
Contributor

I forked them from Nucleus a while back and removed the unneeded dependencies:

https://github.com/inazarenko/protobuf-matchers

@yangustc07
Copy link

@inazarenko Are you planning to merge it into the googletest repo? I also have a use case for it.

@inazarenko
Copy link
Contributor

Are you planning to merge it into the googletest repo? I also have a use case for it.

No, I don't plan to merge it with googletest, but you can just pull my repo and use it. Or clone it if you want to be isolated from any changes I might make (although I don't have any current plans to change anything, it works fine as is for our purposes).

@hickford
Copy link

Internal feature request https://buganizer.corp.google.com/issues/229726259 (Googlers only)

@derekmauro
Copy link
Member

If this is open sourced (and I think it should be), it will be part of the protobuf library, not GoogleTest. There is a lot of cleanup required first though.

@alexolog
Copy link

At the least, remove this from the documentation to avoid confusing people

copybara-service bot pushed a commit to google/fhir that referenced this issue Apr 4, 2023
…he internal versions from the protobuf library. For more context, see: google/googletest#1761

Most immediately, this enables polymorphic proto matching from strings.

E.g., instead of saying

MyProto expected;
ASSERT_OK(ParseTextProto("[contents]", &expected);
EXPECT_THAT(result, EqualsProto(expected));

We can now say

EXPECT_THAT(result, EqualsProto("[contents]"));

PiperOrigin-RevId: 521847154
copybara-service bot pushed a commit to google/fhir that referenced this issue Apr 4, 2023
…he internal versions from the protobuf library. For more context, see: google/googletest#1761

Most immediately, this enables polymorphic proto matching from strings.

E.g., instead of saying

MyProto expected;
ASSERT_OK(ParseTextProto("[contents]", &expected);
EXPECT_THAT(result, EqualsProto(expected));

We can now say

EXPECT_THAT(result, EqualsProto("[contents]"));

PiperOrigin-RevId: 521847154
copybara-service bot pushed a commit to google/fhir that referenced this issue Apr 5, 2023
…he internal versions from the protobuf library. For more context, see: google/googletest#1761

Most immediately, this enables polymorphic proto matching from strings.

E.g., instead of saying

MyProto expected;
ASSERT_OK(ParseTextProto("[contents]", &expected);
EXPECT_THAT(result, EqualsProto(expected));

We can now say

EXPECT_THAT(result, EqualsProto("[contents]"));

PiperOrigin-RevId: 521847154
copybara-service bot pushed a commit to google/fhir that referenced this issue Apr 5, 2023
…he internal versions from the protobuf library. For more context, see: google/googletest#1761

Most immediately, this enables polymorphic proto matching from strings.

E.g., instead of saying

MyProto expected;
ASSERT_OK(ParseTextProto("[contents]", &expected);
EXPECT_THAT(result, EqualsProto(expected));

We can now say

EXPECT_THAT(result, EqualsProto("[contents]"));

PiperOrigin-RevId: 522084017
@devjgm
Copy link
Contributor

devjgm commented Apr 18, 2023

Friendly ping. The docs should remove references to EqualsProto() and any other matches that don't exist externally.

@wffurr
Copy link

wffurr commented Apr 22, 2024

Rather than removing the references, can we have the proto matchers as open source? I would love to use those in my project instead of hacking something together over MessageDifferencer.

@inazarenko
Copy link
Contributor

I'd also love for them to be a part of gTest/gMock.

@wffurr for now perhaps take a look at the repository linked here: #1761 (comment)

@tonyliaoss
Copy link

This seems related to protocolbuffers/protobuf#3142

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests