[CXX-1145] Remove CHECK_OPTIONAL_ARGUMENT_WITHOUT_EQUALITY() macro, define equality/inequality operators where needed Created: 22/Nov/16  Updated: 24/Feb/17  Resolved: 24/Feb/17

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

Type: Task Priority: Major - P3
Reporter: J Rassi Assignee: J Rassi
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to CXX-1050 Add equality operators for options an... Closed

 Description   

The CHECK_OPTIONAL_ARGUMENT_WITHOUT_EQUALITY() macro doesn't check the return value of the getters it tests. For better test coverage, we should define equality operators and inequality operators for the mongocxx types we are currently testing using this macro, and then remove the macro entirely.

Specifically, we will define the following:

    friend MONGOCXX_API bool MONGOCXX_CALL operator==(const write_concern&, const write_concern&);
    friend MONGOCXX_API bool MONGOCXX_CALL operator!=(const write_concern&, const write_concern&);
    friend MONGOCXX_API bool MONGOCXX_CALL operator==(const read_concern&, const read_concern&);
    friend MONGOCXX_API bool MONGOCXX_CALL operator!=(const read_concern&, const read_concern&);
    friend MONGOCXX_API bool MONGOCXX_CALL operator!=(const read_preference&,
                                                      const read_preference&);

Original description:

Currently, CHECK_OPTIONAL_ARGUMENT_WITHOUT_EQUALITY() is used for verifying the existence of getters that return objects which don't provide operator==(). However, in all of our existing uses of this macro, we have no other test coverage that examines the return value of these getters being tested.

To improve our test coverage of these getter methods, we should remove CHECK_OPTIONAL_ARGUMENT_WITHOUT_EQUALITY() and extend CHECK_OPTIONAL_ARGUMENT() to support custom equality checks for non-comparable types.



 Comments   
Comment by Githook User [ 24/Feb/17 ]

Author:

{u'username': u'jrassi', u'name': u'J. Rassi', u'email': u'rassi@10gen.com'}

Message: CXX-1145 Remove CHECK_OPTIONAL_ARGUMENT_WITHOUT_EQUALITY() macro
Branch: master
https://github.com/mongodb/mongo-cxx-driver/commit/7b6a022f7343da74489ccdc49c960c835d3ddc46

Comment by Githook User [ 24/Feb/17 ]

Author:

{u'username': u'jrassi', u'name': u'J. Rassi', u'email': u'rassi@10gen.com'}

Message: CXX-1145 Define operator== and operator!= for write_concern
Branch: master
https://github.com/mongodb/mongo-cxx-driver/commit/4fb62c2e603c73888a95950f538e46e38b2191bd

Comment by Githook User [ 24/Feb/17 ]

Author:

{u'username': u'jrassi', u'name': u'J. Rassi', u'email': u'rassi@10gen.com'}

Message: CXX-1145 Define operator== and operator!= for read_concern
Branch: master
https://github.com/mongodb/mongo-cxx-driver/commit/644647fb752dd847caf4342ddce3cd3df89472b8

Comment by Githook User [ 24/Feb/17 ]

Author:

{u'username': u'jrassi', u'name': u'J. Rassi', u'email': u'rassi@10gen.com'}

Message: CXX-1145 Define operator!= for read_preference
Branch: master
https://github.com/mongodb/mongo-cxx-driver/commit/773a9a36ac30b65eba89e0e35bce48af391d9da0

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