Skip to content

Commit ab92bee

Browse files
Mizuchifacebook-github-bot
authored andcommitted
Print expected struct and actual struct when round trip test fails
Summary: Currently it only prints whether test passes. This diff prints json result if it fails. Reviewed By: thedavekwon Differential Revision: D39010859 fbshipit-source-id: 754016048d0f43318e35624df69fd11d67bcf792
1 parent 4823bbf commit ab92bee

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

third-party/thrift/src/thrift/conformance/GTestHarness.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,17 @@ testing::AssertionResult runRoundTripTest(
5858
}
5959
};
6060

61+
auto toJson = [](const Object& o) {
62+
return folly::toPrettyJson(protocol::toDynamic(o));
63+
};
64+
6165
Object actual = parseAny(*res.value());
6266
Object expected = parseAny(expectedAny);
6367
if (!op::identical<type::struct_t<Object>>(actual, expected)) {
6468
// TODO(afuller): Report out the delta
65-
return testing::AssertionFailure();
69+
return testing::AssertionFailure()
70+
<< "\nInput: " << toJson(parseAny(*roundTrip.request()->value()))
71+
<< "\nExpected: " << toJson(expected) << "\nActual: " << toJson(actual);
6672
}
6773
return testing::AssertionSuccess();
6874
}

0 commit comments

Comments
 (0)