[CXX-1154] Allow stdx::optional to be used in Catch comparison expressions Created: 01/Dec/16  Updated: 17/Apr/18  Resolved: 17/Apr/18

Status: Closed
Project: C++ Driver
Component/s: Testing
Affects Version/s: None
Fix Version/s: 3.3.0-rc0

Type: Task Priority: Major - P3
Reporter: Backlog - CXX Driver Team Assignee: A. Jesse Jiryu Davis
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates CXX-1537 Upgrade Catch from 1.9.4 to 2.2.1 Closed

 Description   

If "a" and "b" are of type stdx::optional<T>, then the test assertion "REQUIRE(a == b);" may not compile under certain configurations.

Specifically, on the driver's current Windows CI hosts (which use use Boost polyfills for stdx), these statements fail to compile with the following error:

error C2338: If you want to output boost::optional, include header <boost/optional/optional_io.hpp>

This is due to the fact that Catch attempts to convert comparison operands to strings with
operator<<(), in case of an assertion failure.

After pulling in optional_io.hpp, the following error is still generated for certain types, even types that Catch is normally perfectly happy to normally include in REQUIRE() comparison statements (like enum class types):

error C2679: binary '<<': no operator found which takes a right-hand operand of type 'T' (or there is no acceptable conversion)

We should come up with some sort of solution that makes it legal to compare objects of type stdx::optional<T> in test cases whenever it is legal to compare objects of type T.



 Comments   
Comment by A. Jesse Jiryu Davis [ 17/Apr/18 ]

This work was done, AFAICT, while updating the vendored Catch2 header.

Generated at Wed Feb 07 22:01:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.