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

unittest.h ASSERT macros have incorrect structure

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.3.1
    • Component/s: Internal Code
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Sprint:
      Dev Tools 2019-09-23, Dev Tools 2019-10-07

      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.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: