Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-43418

unittest.h ASSERT macros have incorrect structure

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.3.1
    • Affects Version/s: None
    • Component/s: Internal Code
    • Labels:
      None
    • Fully Compatible
    • ALL
    • Dev Tools 2019-09-23, Dev Tools 2019-10-07

      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.

            Assignee:
            billy.donahue@mongodb.com Billy Donahue
            Reporter:
            billy.donahue@mongodb.com Billy Donahue
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: