[SERVER-18618] ComparisonAssertion in the unit testing framework should not require overloaded operator << Created: 21/May/15  Updated: 21/May/15  Resolved: 21/May/15

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Adam Midvidy Assignee: Andy Schwerin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

This forces the usage of less expressive assertions on types that don't define such overloads. We could use SFINAE to dispatch to a specialization of ComparisonAssertion that prints the compared values if the types being compared are ostream printable, otherwise omit printing them.



 Comments   
Comment by Andy Schwerin [ 21/May/15 ]

If ASSERT_EQ and its ilk cannot be used for a type because that type does not support the stream put operator, the correct developer action is to write:

ASSERT(EXPR1 == EXPR2);

Or, better yet,

auto expected = EXPR1;
auto actual = EXPR2;
ASSERT(expected == actual) << "Expected " << expected.toString() << ", but found " << actual.toString();

Generated at Thu Feb 08 03:48:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.