[SERVER-43418] unittest.h ASSERT macros have incorrect structure Created: 23/Sep/19  Updated: 29/Oct/23  Resolved: 03/Oct/19

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 4.3.1

Type: Bug Priority: Major - P3
Reporter: Billy Donahue Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Dev Tools 2019-09-23, Dev Tools 2019-10-07
Participants:

 Description   

Two problems:

1)
Dangling else. These macros are the body of an if statement.
if (expression) FAIL(...)
That means they will bind to an immediately subsequent else, a bug.
This code should assert b if cond is true.
If cond is not true, eExpr should run.

    if (cond)
        ASSERT_TRUE(b);
    else {
        eExpr
    }
 
will expand with the else binding to the interior if:
 
    if (cond){
        if(b) {
            FAIL(...)
        } else {
            eExpr
        }
    }

Which doesn't run eExpr unless cond is true.

2)
Should expose a stream() object to append detail. Some do. Many do not.
ASSERT_FOO(x, y, z) << "details go here: uid=" << uid << ", x=" << x;

The macros must be rewritten to follow a standard format.



 Comments   
Comment by Githook User [ 02/Oct/19 ]

Author:

{'name': 'Billy Donahue', 'username': 'BillyDonahue', 'email': 'billy.donahue@mongodb.com'}

Message: SERVER-43418 ASSERT macro repairs

Comment by Billy Donahue [ 23/Sep/19 ]

https://mongodbcr.appspot.com/511080012/

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