src/core/model/test.h
author Tom Henderson <tomh@tomh.org>
Thu, 05 Feb 2015 13:02:44 -0800
changeset 11214 103f62fc7d58
parent 11181 01d91bb3dfb8
child 11356 8589e611d657
permissions -rw-r--r--
small edits on previous commit
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
150
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
9
2c31ae7c94db import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
     3
 * Copyright (c) 2009 University of Washington
9
2c31ae7c94db import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
 *
2c31ae7c94db import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
2c31ae7c94db import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
2c31ae7c94db import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
2c31ae7c94db import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 *
2c31ae7c94db import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
2c31ae7c94db import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2c31ae7c94db import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2c31ae7c94db import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * GNU General Public License for more details.
2c31ae7c94db import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 *
2c31ae7c94db import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
2c31ae7c94db import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
2c31ae7c94db import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
2c31ae7c94db import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 */
2c31ae7c94db import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
5342
3c6109eec550 bug 675: kill old test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5324
diff changeset
    19
#ifndef NS3_TEST_H
3c6109eec550 bug 675: kill old test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5324
diff changeset
    20
#define NS3_TEST_H
9
2c31ae7c94db import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
    22
#include <iostream>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
    23
#include <fstream>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
    24
#include <sstream>
9
2c31ae7c94db import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
#include <string>
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
    26
#include <vector>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
    27
#include <list>
4773
904c1803d5dc test framework should probably work on all supported machines
Craig Dowell <craigdo@ee.washington.edu>
parents: 4772
diff changeset
    28
#include <limits>
4774
066f73df2229 fc11 is pretty picky about headers
Craig Dowell <craigdo@ee.washington.edu>
parents: 4773
diff changeset
    29
#include <stdint.h>
5457
8cb18165e22f Apply Gustavo's patch for MinGW compatibiliy
Craig Dowell <craigdo@ee.washington.edu>
parents: 5441
diff changeset
    30
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    31
#include "system-wall-clock-ms.h"
5457
8cb18165e22f Apply Gustavo's patch for MinGW compatibiliy
Craig Dowell <craigdo@ee.washington.edu>
parents: 5441
diff changeset
    32
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
    33
/**
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
    34
 * \ingroup core
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
    35
 * \defgroup testing Testing
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
    36
 * \brief Tools to define and execute unit tests.
11046
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
    37
 *
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
    38
 * This module lists the normal Testing API.  Most of these
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
    39
 * macros forward to the implementation macros in testingimpl.
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
    40
 * You should generally use these macros only.
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
    41
 */
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
    42
/**
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
    43
 * \ingroup testing
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
    44
 * \defgroup testingimpl Testing Implementation
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
    45
 * \brief Internal implementation of the Testing system.
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
    46
 */
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
    47
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
    48
// 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
    49
// Note on below macros:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
    50
//
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
    51
// When multiple statements are used in a macro, they should be bound together 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
    52
// in a loop syntactically, so the macro can appear safely inside if clauses 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
    53
// or other places that expect a single statement or a statement block.  The
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
    54
// "strange" do while construct is a generally expected best practice for
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
    55
// defining a robust macro.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
    56
//
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
    57
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
    58
/**
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
    59
 * \ingroup testing
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
    60
 * \brief Check if we should assert on errors, and do so
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
    61
 */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    62
#define ASSERT_ON_FAILURE                       \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    63
  do {                                          \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    64
    if (MustAssertOnFailure ())                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    65
      {                                         \
7745
fcf4778c9b16 bug 1371: llvm complains about invalid dereference of zero
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7685
diff changeset
    66
        *(volatile int *)0 = 0;                 \
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    67
      }                                         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    68
  } while (false)
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    69
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
    70
/**
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
    71
 * \ingroup testing
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
    72
 * \brief If we shouldn't continue on errors, return
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
    73
 */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    74
#define CONTINUE_ON_FAILURE                                             \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    75
  do {                                                                  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    76
    if (!MustContinueOnFailure ())                                      \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    77
      {                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    78
        return;                                                         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    79
      }                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    80
  } while (false)
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    81
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
    82
/**
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
    83
 * \ingroup testing
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
    84
 * \brief If we shouldn't continue on errors, return test status
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
    85
 */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    86
#define CONTINUE_ON_FAILURE_RETURNS_BOOL                                \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    87
  do {                                                                  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    88
    if (!MustContinueOnFailure ())                                      \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    89
      {                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    90
        return IsStatusFailure ();                                      \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    91
      }                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    92
  } while (false)
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    93
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
    94
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
    95
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
    96
// ===========================================================================
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
    97
// Test for equality (generic version)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
    98
// ===========================================================================
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
    99
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   100
/**
11046
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
   101
 * \ingroup testingimpl
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   102
 * \brief Test that an actual and expected (limit) value are equal and report
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   103
 * and abort if not.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   104
 */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   105
#define NS_TEST_ASSERT_MSG_EQ_INTERNAL(actual, limit, msg, file, line)  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   106
  do {                                                                  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   107
    if (!((actual) == (limit)))                                         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   108
      {                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   109
        ASSERT_ON_FAILURE;                                              \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   110
        std::ostringstream msgStream;                                   \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   111
        msgStream << msg;                                               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   112
        std::ostringstream actualStream;                                \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   113
        actualStream << actual;                                         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   114
        std::ostringstream limitStream;                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   115
        limitStream << limit;                                           \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   116
        ReportTestFailure (std::string (#actual) + " (actual) == " +    \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   117
                           std::string (#limit) + " (limit)",           \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   118
                           actualStream.str (), limitStream.str (),     \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   119
                           msgStream.str (), file, line);               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   120
        CONTINUE_ON_FAILURE;                                            \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   121
      }                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   122
  } while (false)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   123
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   124
/**
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   125
 * \ingroup testing
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   126
 *
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   127
 * \brief Test that an actual and expected (limit) value are equal and report
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   128
 * and abort if not.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   129
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   130
 * Check to see if the expected (limit) value is equal to the actual value found
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   131
 * in a test case.  If the two values are equal nothing happens, but if the 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   132
 * comparison fails, an error is reported in a consistent way and the execution
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   133
 * of the current test case is aborted.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   134
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   135
 * The message is interpreted as a stream, for example:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   136
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   137
 * \code
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   138
 * NS_TEST_ASSERT_MSG_EQ (result, true, 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   139
 *      "cannot open file " << filename << " in test");
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   140
 * \endcode
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   141
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   142
 * is legal.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   143
 * 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   144
 * \param actual Expression for the actual value found during the test.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   145
 * \param limit Expression for the expected value of the test.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   146
 * \param msg Message that is output if the test does not pass.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   147
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   148
 * \warning Do not use this macro if you are comparing floating point numbers
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   149
 * (float or double) as it is unlikely to do what you expect.  Use 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   150
 * NS_TEST_ASSERT_MSG_EQ_TOL instead.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   151
 */
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   152
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg) \
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   153
  NS_TEST_ASSERT_MSG_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   154
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   155
/**
11046
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
   156
 * \ingroup testingimpl
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   157
 * \brief Test that an actual and expected (limit) value are equal and report
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   158
 * and abort if not.
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   159
 */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   160
#define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_INTERNAL(actual, limit, msg, file, line) \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   161
  do {                                                                  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   162
    if (!((actual) == (limit)))                                         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   163
      {                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   164
        ASSERT_ON_FAILURE;                                              \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   165
        std::ostringstream msgStream;                                   \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   166
        msgStream << msg;                                               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   167
        std::ostringstream actualStream;                                \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   168
        actualStream << actual;                                         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   169
        std::ostringstream limitStream;                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   170
        limitStream << limit;                                           \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   171
        ReportTestFailure (std::string (#actual) + " (actual) == " +        \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   172
                       std::string (#limit) + " (limit)",               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   173
                       actualStream.str (), limitStream.str (),         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   174
                       msgStream.str (), file, line);                   \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   175
        CONTINUE_ON_FAILURE_RETURNS_BOOL;                               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   176
      }                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   177
  } while (false)
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   178
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   179
/**
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   180
 * \ingroup testing
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   181
 *
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   182
 * \brief Test that an actual and expected (limit) value are equal and report
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   183
 * and abort if not.
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   184
 *
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   185
 * Check to see if the expected (limit) value is equal to the actual value found
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   186
 * in a test case.  If the two values are equal nothing happens, but if the 
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   187
 * comparison fails, an error is reported in a consistent way and the execution
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   188
 * of the current test case is aborted.
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   189
 *
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   190
 * The message is interpreted as a stream, for example:
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   191
 *
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   192
 * \code
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   193
 * NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (result, true, 
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   194
 *      "cannot open file " << filename << " in test");
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   195
 * \endcode
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   196
 *
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   197
 * is legal.
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   198
 * 
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   199
 * \param actual Expression for the actual value found during the test.
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   200
 * \param limit Expression for the expected value of the test.
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   201
 * \param msg Message that is output if the test does not pass.
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   202
 *
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   203
 * \warning Do not use this macro if you are comparing floating point numbers
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   204
 * (float or double) as it is unlikely to do what you expect.  Use 
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   205
 * NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_TOL instead.
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   206
 *
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   207
 * This function returns a boolean value.
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   208
 *
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   209
 */
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   210
#define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL(actual, limit, msg) \
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   211
  NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   212
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   213
/**
11046
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
   214
 * \ingroup testingimpl
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   215
 * \brief Test that an actual and expected (limit) value are equal and report
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   216
 * if not.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   217
 * 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   218
 * Required to avoid use of return statement which allows use in methods 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   219
 * (esp. callbacks) returning void.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   220
 */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   221
#define NS_TEST_EXPECT_MSG_EQ_INTERNAL(actual, limit, msg, file, line)  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   222
  do {                                                                  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   223
    if (!((actual) == (limit)))                                         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   224
      {                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   225
        ASSERT_ON_FAILURE;                                              \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   226
        std::ostringstream msgStream;                                   \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   227
        msgStream << msg;                                               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   228
        std::ostringstream actualStream;                                \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   229
        actualStream << actual;                                         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   230
        std::ostringstream limitStream;                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   231
        limitStream << limit;                                           \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   232
        ReportTestFailure (std::string (#actual) + " (actual) == " +        \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   233
                       std::string (#limit) + " (limit)",               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   234
                       actualStream.str (), limitStream.str (),         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   235
                       msgStream.str (), file, line);                   \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   236
      }                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   237
  } while (false)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   238
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   239
/**
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   240
 * \ingroup testing
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   241
 *
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   242
 * \brief Test that an actual and expected (limit) value are equal and report
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   243
 * if not.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   244
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   245
 * Check to see if the expected (lmit) value is equal to the actual value found
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   246
 * in a test case.  If the two values are equal nothing happens, but if the 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   247
 * comparison fails, an error is reported in a consistent way.  EXPECT* macros
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   248
 * do not return if an error is detected.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   249
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   250
 * The message is interpreted as a stream, for example:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   251
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   252
 * \code
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   253
 * NS_TEST_EXPECT_MSG_EQUAL (result, true, 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   254
 *      "cannot open file " << filename << " in test");
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   255
 * \endcode
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   256
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   257
 * is legal.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   258
 * 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   259
 * \param actual Expression for the actual value found during the test.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   260
 * \param limit Expression for the expected value of the test.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   261
 * \param msg Message that is output if the test does not pass.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   262
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   263
 * \warning Do not use this macro if you are comparing floating point numbers
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   264
 * (float or double) as it is unlikely to do what you expect.  Use 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   265
 * NS_TEST_EXPECT_MSG_EQ_TOL instead.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   266
 */
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   267
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg) \
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   268
  NS_TEST_EXPECT_MSG_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   269
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   270
// ===========================================================================
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   271
// Test for equality with a provided tolerance (use for floating point 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   272
// comparisons -- both float and double)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   273
// ===========================================================================
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   274
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   275
/**
11046
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
   276
 * \ingroup testingimpl
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   277
 * \brief Test that actual and expected (limit) values are equal to plus
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   278
 * or minus some tolerance and report and abort if not.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   279
 */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   280
#define NS_TEST_ASSERT_MSG_EQ_TOL_INTERNAL(actual, limit, tol, msg, file, line) \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   281
  do {                                                                  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   282
    if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol))       \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   283
      {                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   284
        ASSERT_ON_FAILURE;                                              \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   285
        std::ostringstream msgStream;                                   \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   286
        msgStream << msg;                                               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   287
        std::ostringstream actualStream;                                \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   288
        actualStream << actual;                                         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   289
        std::ostringstream limitStream;                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   290
        limitStream << limit << " +- " << tol;                          \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   291
        std::ostringstream condStream;                                  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   292
        condStream << #actual << " (actual) < " << #limit               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   293
                   << " (limit) + " << #tol << " (tol) && "             \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   294
                   << #actual << " (actual) > " << #limit               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   295
                   << " (limit) - " << #tol << " (tol)";                \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   296
        ReportTestFailure (condStream.str (), actualStream.str (),          \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   297
                       limitStream.str (), msgStream.str (),            \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   298
                       file, line);                                     \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   299
        CONTINUE_ON_FAILURE;                                            \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   300
      }                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   301
  } while (false)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   302
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   303
/**
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   304
 * \ingroup testing
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   305
 *
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   306
 * \brief Test that actual and expected (limit) values are equal to plus
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   307
 * or minus some tolerance and report and abort if not.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   308
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   309
 * Check to see if the expected (limit) value is equal to the actual value found
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   310
 * in a test case to some tolerance.  This is not the same thing as asking if
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   311
 * two floating point are equal to within some epsilon, but is useful for that
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   312
 * case.  This assertion is geared toward more of a measurement problem.
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   313
 * Consider measuring a physical rod of some kind that you have ordered.
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   314
 * You need to determine if it is "good."  You want to measure the rod
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   315
 * to an arbitrary precision of sixteen significant figures, you will
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   316
 * measure the rod to determine if its length is within the tolerances
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   317
 * you provided.  For example, 12.00 inches plus or minus .005 inch
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   318
 * may be just fine.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   319
 * 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   320
 * In ns-3, you might want to measure a signal to noise ratio and check to see
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   321
 * if the answer is what you expect.  If you naively measure (double)1128.93 and
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   322
 * compare this number with a constant 1128.93 you are almost certainly going to
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   323
 * have your test fail because of floating point rounding errors.  We provide a
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   324
 * floating point comparison function ns3::TestDoubleIsEqual() but you will 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   325
 * probably quickly find that is not what you want either.  It may turn out to
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   326
 * be the case that when you measured an snr that printed as 1128.93, what was 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   327
 * actually measured was something more like 1128.9287653857625442 for example.
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   328
 * Given that the double epsilon is on the order of 0.0000000000000009,
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   329
 * you would need to provide sixteen significant figures of expected value
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   330
 * for this kind of test to pass even with a typical test for floating point
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   331
 * "approximate equality."  That is clearly not required or desired.
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   332
 * You really want to be able to provide 1128.93 along with a tolerance
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   333
 * just like you provided 12 inches +- 0.005 inch above.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   334
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   335
 * This assertion is designed for real measurements by taking into account
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   336
 * measurement tolerances.  By doing so it also automatically compensates for 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   337
 * floating point rounding errors.    If you really want to check floating point
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   338
 * equality down to the numeric_limits<double>::epsilon () range, consider
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   339
 * using ns3::TestDoubleIsEqual().
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   340
 *
10591
5770becb0bcb Mixing signed and unsigned types can lead to misleading results in NS_TEST macros.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10587
diff changeset
   341
 * \note Mixing signed and unsigned types can lead to misleading results.
5770becb0bcb Mixing signed and unsigned types can lead to misleading results in NS_TEST macros.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10587
diff changeset
   342
 *
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   343
 * The message is interpreted as a stream, for example:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   344
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   345
 * \code
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   346
 * NS_TEST_ASSERT_MSG_EQ_TOL (snr, 1128.93, 0.005, "wrong snr (" << snr << ") in test");
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   347
 * \endcode
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   348
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   349
 * is legal.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   350
 * 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   351
 * \param actual Expression for the actual value found during the test.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   352
 * \param limit Expression for the expected value of the test.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   353
 * \param tol Tolerance of the test.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   354
 * \param msg Message that is output if the test does not pass.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   355
 */
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   356
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)                 \
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   357
  NS_TEST_ASSERT_MSG_EQ_TOL_INTERNAL (actual, limit, tol, msg, __FILE__, __LINE__)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   358
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   359
/**
11046
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
   360
 * \ingroup testingimpl
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   361
 * \brief Test that actual and expected (limit) values are equal to plus
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   362
 * or minus some tolerance and report and abort if not.
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   363
 */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   364
#define NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL_INTERNAL(actual, limit, tol, msg, file, line) \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   365
  do {                                                                  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   366
    if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol))       \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   367
      {                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   368
        ASSERT_ON_FAILURE;                                              \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   369
        std::ostringstream msgStream;                                   \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   370
        msgStream << msg;                                               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   371
        std::ostringstream actualStream;                                \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   372
        actualStream << actual;                                         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   373
        std::ostringstream limitStream;                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   374
        limitStream << limit << " +- " << tol;                          \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   375
        std::ostringstream condStream;                                  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   376
        condStream << #actual << " (actual) < " << #limit               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   377
                   << " (limit) + " << #tol << " (tol) && "             \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   378
                   << #actual << " (actual) > " << #limit               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   379
                   << " (limit) - " << #tol << " (tol)";                \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   380
        ReportTestFailure (condStream.str (), actualStream.str (),          \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   381
                       limitStream.str (), msgStream.str (),            \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   382
                       file, line);                                     \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   383
        CONTINUE_ON_FAILURE_RETURNS_BOOL;                               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   384
      }                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   385
  } while (false)
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   386
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   387
/**
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   388
 * \ingroup testing
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   389
 *
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   390
 * \brief Test that actual and expected (limit) values are equal to plus
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   391
 * or minus some tolerance and report and abort if not.
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   392
 *
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   393
 * Check to see if the expected (limit) value is equal to the actual value found
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   394
 * in a test case to some tolerance.  This is not the same thing as asking if
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   395
 * two floating point are equal to within some epsilon, but is useful for that
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   396
 * case.  This assertion is geared toward more of a measurement problem.
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   397
 * Consider measuring a physical rod of some kind that you have ordered.
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   398
 * You need to determine if it is "good."  You want to measure the rod
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   399
 * to an arbitrary precision of sixteen significant figures, you will
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   400
 * measure the rod to determine if its length is within the tolerances
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   401
 * you provided.  For example, 12.00 inches plus or minus .005 inch
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   402
 * may be just fine.
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   403
 * 
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   404
 * In ns-3, you might want to measure a signal to noise ratio and check to see
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   405
 * if the answer is what you expect.  If you naively measure (double)1128.93 and
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   406
 * compare this number with a constant 1128.93 you are almost certainly going to
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   407
 * have your test fail because of floating point rounding errors.  We provide a
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   408
 * floating point comparison function ns3::TestDoubleIsEqual() but you will 
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   409
 * probably quickly find that is not what you want either.  It may turn out to
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   410
 * be the case that when you measured an snr that printed as 1128.93, what was 
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   411
 * actually measured was something more like 1128.9287653857625442 for example.
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   412
 * Given that the double epsilon is on the order of 0.0000000000000009,
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   413
 * you would need to provide sixteen significant figures of expected value
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   414
 * for this kind of test to pass even with a typical test for floating point
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   415
 * "approximate equality."  That is clearly not required or desired.
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   416
 * You really want to be able to provide  1128.93 along with a tolerance
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   417
 * just like you provided 12 inches +- 0.005 inch above.
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   418
 *
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   419
 * This assertion is designed for real measurements by taking into account
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   420
 * measurement tolerances.  By doing so it also automatically compensates for 
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   421
 * floating point rounding errors.    If you really want to check floating point
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   422
 * equality down to the numeric_limits<double>::epsilon () range,
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   423
 * consider using ns3::TestDoubleIsEqual().
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   424
 *
10591
5770becb0bcb Mixing signed and unsigned types can lead to misleading results in NS_TEST macros.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10587
diff changeset
   425
 * \note Mixing signed and unsigned types can lead to misleading results.
5770becb0bcb Mixing signed and unsigned types can lead to misleading results in NS_TEST macros.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10587
diff changeset
   426
 *
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   427
 * The message is interpreted as a stream, for example:
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   428
 *
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   429
 * \code
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   430
 * NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL (snr, 1128.93, 0.005, "wrong snr (" << snr << ") in test");
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   431
 * \endcode
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   432
 *
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   433
 * is legal.
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   434
 * 
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   435
 * \param actual Expression for the actual value found during the test.
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   436
 * \param limit Expression for the expected value of the test.
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   437
 * \param tol Tolerance of the test.
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   438
 * \param msg Message that is output if the test does not pass.
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   439
 *
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   440
 * This function returns a boolean value.
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   441
 *
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   442
 */
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   443
#define NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL(actual, limit, tol, msg)                 \
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   444
  NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL_INTERNAL (actual, limit, tol, msg, __FILE__, __LINE__)
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   445
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   446
/**
11046
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
   447
 * \ingroup testingimpl
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   448
 * \brief Test that actual and expected (limit) values are equal to plus or minus
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   449
 * some tolerance and report if not.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   450
 * 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   451
 * Required to avoid use of return statement which allows use in methods 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   452
 * (esp. callbacks) returning void.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   453
 */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   454
#define NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL(actual, limit, tol, msg, file, line) \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   455
  do {                                                                  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   456
    if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol))       \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   457
      {                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   458
        ASSERT_ON_FAILURE;                                              \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   459
        std::ostringstream msgStream;                                   \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   460
        msgStream << msg;                                               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   461
        std::ostringstream actualStream;                                \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   462
        actualStream << actual;                                         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   463
        std::ostringstream limitStream;                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   464
        limitStream << limit << " +- " << tol;                          \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   465
        std::ostringstream condStream;                                  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   466
        condStream << #actual << " (actual) < " << #limit               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   467
                   << " (limit) + " << #tol << " (tol) && "             \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   468
                   << #actual << " (actual) > " << #limit               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   469
                   << " (limit) - " << #tol << " (tol)";                \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   470
        ReportTestFailure (condStream.str (), actualStream.str (),          \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   471
                       limitStream.str (), msgStream.str (),            \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   472
                       file, line);                                     \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   473
      }                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   474
  } while (false)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   475
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   476
/**
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   477
 * \ingroup testing
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   478
 *
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   479
 * \brief Test that actual and expected (limit) values are equal to plus
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   480
 * or minus some tolerance and report if not.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   481
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   482
 * Check to see if the expected (limit) value is equal to the actual value found
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   483
 * in a test case to some tolerance.  This is not the same thing as asking if
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   484
 * two floating point are equal to within some epsilon, but is useful for that
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   485
 * case.  This assertion is geared toward more of a measurement problem.
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   486
 * Consider measuring a physical rod of some kind that you have ordered.
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   487
 * You need to  determine if it is "good."  You want to measure the rod
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   488
 * to an arbitrary precision  of sixteen significant figures,
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   489
 * you will measure the rod to determine if its length is within
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   490
 * the tolerances you provided.  For example, 12.00 inches plus 
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   491
 * or minus .005 inch may be just fine.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   492
 * 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   493
 * In ns-3, you might want to measure a signal to noise ratio and check to see
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   494
 * if the answer is what you expect.  If you naively measure (double)1128.93 and
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   495
 * compare this number with a constant 1128.93 you are almost certainly going to
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   496
 * have your test fail because of floating point rounding errors.  We provide a
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   497
 * floating point comparison function ns3::TestDoubleIsEqual() but you will 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   498
 * probably quickly find that is not what you want either.  It may turn out to
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   499
 * be the case that when you measured an snr that printed as 1128.93, what was 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   500
 * actually measured was something more like 1128.9287653857625442 for example.
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   501
 * Given that the double epsilon is on the order of 0.0000000000000009,
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   502
 * you would  need to provide sixteen significant figures of expected value
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   503
 * for this kind of test to pass even with a typical test for floating point
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   504
 * "approximate equality."  That is clearly not required or desired.
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   505
 * You really want to be able to provide 1128.93 along with a tolerance
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   506
 * just like you provided 12 inches +- 0.005 inch above.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   507
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   508
 * This assertion is designed for real measurements by taking into account
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   509
 * measurement tolerances.  By doing so it also automatically compensates for 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   510
 * floating point rounding errors.    If you really want to check floating point
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   511
 * equality down to the numeric_limits<double>::epsilon () range,
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   512
 * consider using ns3::TestDoubleIsEqual().
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   513
 *
10591
5770becb0bcb Mixing signed and unsigned types can lead to misleading results in NS_TEST macros.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10587
diff changeset
   514
 * \note Mixing signed and unsigned types can lead to misleading results.
5770becb0bcb Mixing signed and unsigned types can lead to misleading results in NS_TEST macros.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10587
diff changeset
   515
 *
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   516
 * The message is interpreted as a stream, for example:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   517
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   518
 * \code
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   519
 * NS_TEST_EXPECT_MSG_EQ_TOL (snr, 1128.93, 0.005, "wrong snr (" << snr << ") in test");
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   520
 * \endcode
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   521
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   522
 * is legal.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   523
 * 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   524
 * \param actual Expression for the actual value found during the test.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   525
 * \param limit Expression for the expected value of the test.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   526
 * \param tol Tolerance of the test.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   527
 * \param msg Message that is output if the test does not pass.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   528
 */
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   529
#define NS_TEST_EXPECT_MSG_EQ_TOL(actual, limit, tol, msg) \
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   530
  NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL (actual, limit, tol, msg, __FILE__, __LINE__)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   531
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   532
// ===========================================================================
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   533
// Test for inequality
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   534
// ===========================================================================
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   535
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   536
/**
11046
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
   537
 * \ingroup testingimpl
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   538
 * \brief Test that an actual and expected (limit) value are not equal and 
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   539
 * report and abort if not.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   540
 */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   541
#define NS_TEST_ASSERT_MSG_NE_INTERNAL(actual, limit, msg, file, line)  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   542
  do {                                                                  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   543
    if (!((actual) != (limit)))                                         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   544
      {                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   545
        ASSERT_ON_FAILURE;                                              \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   546
        std::ostringstream msgStream;                                   \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   547
        msgStream << msg;                                               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   548
        std::ostringstream actualStream;                                \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   549
        actualStream << actual;                                         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   550
        std::ostringstream limitStream;                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   551
        limitStream << limit;                                           \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   552
        ReportTestFailure (std::string (#actual) + " (actual) != " +        \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   553
                       std::string (#limit) + " (limit)",               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   554
                       actualStream.str (), limitStream.str (),         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   555
                       msgStream.str (), file, line);                   \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   556
        CONTINUE_ON_FAILURE;                                            \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   557
      }                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   558
  } while (false)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   559
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   560
/**
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   561
 * \ingroup testing
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   562
 *
7685
a8ed3c1c82cc fix doxygen errors
Tom Henderson <tomh@tomh.org>
parents: 7600
diff changeset
   563
 * \brief Test that an actual and expected (limit) value are not equal and 
a8ed3c1c82cc fix doxygen errors
Tom Henderson <tomh@tomh.org>
parents: 7600
diff changeset
   564
 * report and abort if not.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   565
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   566
 * Check to see if the expected (limit) value is not equal to the actual value
7685
a8ed3c1c82cc fix doxygen errors
Tom Henderson <tomh@tomh.org>
parents: 7600
diff changeset
   567
 * found in a test case.  If the two values are not equal nothing happens, but 
a8ed3c1c82cc fix doxygen errors
Tom Henderson <tomh@tomh.org>
parents: 7600
diff changeset
   568
 * if the comparison fails, an error is reported in a consistent way and the 
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   569
 * execution of the current test case is aborted.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   570
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   571
 * The message is interpreted as a stream, for example:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   572
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   573
 * \code
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   574
 * NS_TEST_ASSERT_MSG_NE (result, false, 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   575
 *      "cannot open file " << filename << " in test");
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   576
 * \endcode
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   577
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   578
 * is legal.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   579
 * 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   580
 * \param actual Expression for the actual value found during the test.
7685
a8ed3c1c82cc fix doxygen errors
Tom Henderson <tomh@tomh.org>
parents: 7600
diff changeset
   581
 * \param limit Expression for the value that actual is tested against.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   582
 * \param msg Message that is output if the test does not pass.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   583
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   584
 * \warning Do not use this macro if you are comparing floating point numbers
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   585
 * (float or double).  Use NS_TEST_ASSERT_MSG_FLNE instead.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   586
 */
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   587
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg) \
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   588
  NS_TEST_ASSERT_MSG_NE_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   589
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   590
/**
11046
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
   591
 * \ingroup testingimpl
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   592
 * \brief Test that an actual and expected (limit) value are not equal and 
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   593
 * report and abort if not.
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   594
 */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   595
#define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL_INTERNAL(actual, limit, msg, file, line) \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   596
  do {                                                                  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   597
    if (!((actual) != (limit)))                                         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   598
      {                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   599
        ASSERT_ON_FAILURE;                                              \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   600
        std::ostringstream msgStream;                                   \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   601
        msgStream << msg;                                               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   602
        std::ostringstream actualStream;                                \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   603
        actualStream << actual;                                         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   604
        std::ostringstream limitStream;                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   605
        limitStream << limit;                                           \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   606
        ReportTestFailure (std::string (#actual) + " (actual) != " +        \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   607
                       std::string (#limit) + " (limit)",               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   608
                       actualStream.str (), limitStream.str (),         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   609
                       msgStream.str (), file, line);                   \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   610
        CONTINUE_ON_FAILURE_RETURNS_BOOL;                               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   611
      }                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   612
  } while (false)
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   613
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   614
/**
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   615
 * \ingroup testing
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   616
 *
7685
a8ed3c1c82cc fix doxygen errors
Tom Henderson <tomh@tomh.org>
parents: 7600
diff changeset
   617
 * \brief Test that an actual and expected (limit) value are not equal and 
a8ed3c1c82cc fix doxygen errors
Tom Henderson <tomh@tomh.org>
parents: 7600
diff changeset
   618
 * report and abort if not.
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   619
 *
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   620
 * Check to see if the expected (limit) value is not equal to the actual value
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   621
 * found in a test case.  If the two values are equal nothing happens, but if 
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   622
 * the comparison fails, an error is reported in a consistent way and the 
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   623
 * execution of the current test case is aborted.
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   624
 *
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   625
 * The message is interpreted as a stream, for example:
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   626
 *
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   627
 * \code
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   628
 * NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL (result, false, 
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   629
 *      "cannot open file " << filename << " in test");
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   630
 * \endcode
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   631
 *
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   632
 * is legal.
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   633
 * 
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   634
 * \param actual Expression for the actual value found during the test.
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   635
 * \param limit Expression for the expected value of the test.
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   636
 * \param msg Message that is output if the test does not pass.
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   637
 *
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   638
 * \warning Do not use this macro if you are comparing floating point numbers
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   639
 * (float or double).  Use NS_TEST_ASSERT_MSG_FLNE instead.
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   640
 *
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   641
 * This function returns a boolean value.
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   642
 *
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   643
 */
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   644
#define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL(actual, limit, msg) \
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   645
  NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   646
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
   647
/**
11046
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
   648
 * \ingroup testingimpl
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   649
 * \brief Test that an actual and expected (limit) value are not equal and 
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   650
 * report if not.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   651
 * 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   652
 * Required to avoid use of return statement which allows use in methods 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   653
 * (callbacks) returning void.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   654
 */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   655
#define NS_TEST_EXPECT_MSG_NE_INTERNAL(actual, limit, msg, file, line)  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   656
  do {                                                                  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   657
    if (!((actual) != (limit)))                                         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   658
      {                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   659
        ASSERT_ON_FAILURE;                                              \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   660
        std::ostringstream msgStream;                                   \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   661
        msgStream << msg;                                               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   662
        std::ostringstream actualStream;                                \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   663
        actualStream << actual;                                         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   664
        std::ostringstream limitStream;                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   665
        limitStream << limit;                                           \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   666
        ReportTestFailure (std::string (#actual) + " (actual) != " +        \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   667
                       std::string (#limit) + " (limit)",               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   668
                       actualStream.str (), limitStream.str (),         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   669
                       msgStream.str (), file, line);                   \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   670
      }                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   671
  } while (false)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   672
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   673
/**
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   674
 * \ingroup testing
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   675
 *
7685
a8ed3c1c82cc fix doxygen errors
Tom Henderson <tomh@tomh.org>
parents: 7600
diff changeset
   676
 * \brief Test that an actual and expected (limit) value are not equal and 
a8ed3c1c82cc fix doxygen errors
Tom Henderson <tomh@tomh.org>
parents: 7600
diff changeset
   677
 * report if not.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   678
 *
7685
a8ed3c1c82cc fix doxygen errors
Tom Henderson <tomh@tomh.org>
parents: 7600
diff changeset
   679
 * Check to see if the expected (limit) value is not equal to the actual value 
a8ed3c1c82cc fix doxygen errors
Tom Henderson <tomh@tomh.org>
parents: 7600
diff changeset
   680
 * found in a test case.  If the two values are not equal nothing happens, but 
a8ed3c1c82cc fix doxygen errors
Tom Henderson <tomh@tomh.org>
parents: 7600
diff changeset
   681
 * if the comparison fails, an error is reported in a consistent way.  EXPECT* 
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   682
 * macros do not return if an error is detected.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   683
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   684
 * The message is interpreted as a stream, for example:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   685
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   686
 * \code
7685
a8ed3c1c82cc fix doxygen errors
Tom Henderson <tomh@tomh.org>
parents: 7600
diff changeset
   687
 * NS_TEST_EXPECT_MSG_NE (result, false, 
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   688
 *      "cannot open file " << filename << " in test");
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   689
 * \endcode
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   690
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   691
 * is legal.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   692
 * 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   693
 * \param actual Expression for the actual value found during the test.
7685
a8ed3c1c82cc fix doxygen errors
Tom Henderson <tomh@tomh.org>
parents: 7600
diff changeset
   694
 * \param limit Expression for the value that actual is tested against.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   695
 * \param msg Message that is output if the test does not pass.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   696
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   697
 * \warning Do not use this macro if you are comparing floating point numbers
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   698
 * (float or double).  Use NS_TEST_EXPECT_MSG_FLNE instead.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   699
 */
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   700
#define NS_TEST_EXPECT_MSG_NE(actual, limit, msg) \
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   701
  NS_TEST_EXPECT_MSG_NE_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   702
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   703
// ===========================================================================
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   704
// Test for less than relation
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   705
// ===========================================================================
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   706
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   707
/**
11046
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
   708
 * \ingroup testingimpl
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   709
 * \brief Test that an actual value is less than a limit and report and abort
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   710
 * if not.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   711
 */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   712
#define NS_TEST_ASSERT_MSG_LT_INTERNAL(actual, limit, msg, file, line)  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   713
  do {                                                                  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   714
    if (!((actual) < (limit)))                                          \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   715
      {                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   716
        ASSERT_ON_FAILURE;                                              \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   717
        std::ostringstream msgStream;                                   \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   718
        msgStream << msg;                                               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   719
        std::ostringstream actualStream;                                \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   720
        actualStream << actual;                                         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   721
        std::ostringstream limitStream;                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   722
        limitStream << limit;                                           \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   723
        ReportTestFailure (std::string (#actual) + " (actual) < " +         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   724
                       std::string (#limit) + " (limit)",               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   725
                       actualStream.str (), limitStream.str (),         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   726
                       msgStream.str (), file, line);                   \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   727
        CONTINUE_ON_FAILURE;                                            \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   728
      }                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   729
  } while (false)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   730
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   731
/**
11046
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
   732
 * \ingroup testingimpl
10884
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   733
 * \brief Test that an actual value is less than or equal to a limit and report
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   734
 * and abort if not.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   735
 */
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   736
#define NS_TEST_ASSERT_MSG_LT_OR_EQ_INTERNAL(actual, limit, msg, file, line)  \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   737
  do {                                                                  \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   738
    if (!((actual) <= (limit)))                                          \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   739
      {                                                                 \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   740
        ASSERT_ON_FAILURE;                                              \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   741
        std::ostringstream msgStream;                                   \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   742
        msgStream << msg;                                               \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   743
        std::ostringstream actualStream;                                \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   744
        actualStream << actual;                                         \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   745
        std::ostringstream limitStream;                                 \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   746
        limitStream << limit;                                           \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   747
        ReportTestFailure (std::string (#actual) + " (actual) < " +         \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   748
                       std::string (#limit) + " (limit)",               \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   749
                       actualStream.str (), limitStream.str (),         \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   750
                       msgStream.str (), file, line);                   \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   751
        CONTINUE_ON_FAILURE;                                            \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   752
      }                                                                 \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   753
  } while (false)
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   754
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   755
/**
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   756
 * \ingroup testing
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   757
 *
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   758
 * \brief Test that an actual value is less than a limit and report and abort
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   759
 * if not.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   760
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   761
 * Check to see if the actual value found in a test case is less than the 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   762
 * limit value.  If the actual value is lesser nothing happens, but if the 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   763
 * check fails, an error is reported in a consistent way and the execution
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   764
 * of the current test case is aborted.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   765
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   766
 * The message is interpreted as a stream.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   767
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   768
 * \param actual Expression for the actual value found during the test.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   769
 * \param limit Expression for the limit value of the test.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   770
 * \param msg Message that is output if the test does not pass.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   771
 */
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   772
#define NS_TEST_ASSERT_MSG_LT(actual, limit, msg) \
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   773
  NS_TEST_ASSERT_MSG_LT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   774
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   775
/**
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   776
 * \ingroup testing
10884
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   777
 *
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   778
 * \brief Test that an actual value is less than or equal to a limit and
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   779
 * report and abort if not.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   780
 *
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   781
 * Check to see if the actual value found in a test case is less than or equal
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   782
 * to the limit value.  If the actual value is lesser or equal nothing happens,
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   783
 * but if the check fails, an error is reported in a consistent way and the
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   784
 * execution of the current test case is aborted.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   785
 *
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   786
 * The message is interpreted as a stream.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   787
 *
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   788
 * \param actual Expression for the actual value found during the test.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   789
 * \param limit Expression for the limit value of the test.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   790
 * \param msg Message that is output if the test does not pass.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   791
 */
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   792
#define NS_TEST_ASSERT_MSG_LT_OR_EQ(actual, limit, msg) \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   793
  NS_TEST_ASSERT_MSG_LT_OR_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   794
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   795
/**
11046
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
   796
 * \ingroup testingimpl
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   797
 * \brief Test that an actual value is less than a limit and report if not.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   798
 * 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   799
 * Required to avoid use of return statement which allows use in methods 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   800
 * (callbacks) returning void.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   801
 */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   802
#define NS_TEST_EXPECT_MSG_LT_INTERNAL(actual, limit, msg, file, line)  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   803
  do {                                                                  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   804
    if (!((actual) < (limit)))                                          \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   805
      {                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   806
        ASSERT_ON_FAILURE;                                              \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   807
        std::ostringstream msgStream;                                   \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   808
        msgStream << msg;                                               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   809
        std::ostringstream actualStream;                                \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   810
        actualStream << actual;                                         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   811
        std::ostringstream limitStream;                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   812
        limitStream << limit;                                           \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   813
        ReportTestFailure (std::string (#actual) + " (actual) < " +         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   814
                       std::string (#limit) + " (limit)",               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   815
                       actualStream.str (), limitStream.str (),         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   816
                       msgStream.str (), file, line);                   \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   817
      }                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   818
  } while (false)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   819
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   820
/**
11046
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
   821
 * \ingroup testingimpl
10884
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   822
 * \brief Test that an actual value is less than or equal to a limit and report
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   823
 * if not.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   824
 *
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   825
 * Required to avoid use of return statement which allows use in methods
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   826
 * (callbacks) returning void.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   827
 */
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   828
#define NS_TEST_EXPECT_MSG_LT_OR_EQ_INTERNAL(actual, limit, msg, file, line)  \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   829
  do {                                                                  \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   830
    if (!((actual) <= (limit)))                                          \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   831
      {                                                                 \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   832
        ASSERT_ON_FAILURE;                                              \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   833
        std::ostringstream msgStream;                                   \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   834
        msgStream << msg;                                               \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   835
        std::ostringstream actualStream;                                \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   836
        actualStream << actual;                                         \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   837
        std::ostringstream limitStream;                                 \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   838
        limitStream << limit;                                           \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   839
        ReportTestFailure (std::string (#actual) + " (actual) < " +         \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   840
                       std::string (#limit) + " (limit)",               \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   841
                       actualStream.str (), limitStream.str (),         \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   842
                       msgStream.str (), file, line);                   \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   843
      }                                                                 \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   844
  } while (false)
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   845
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   846
/**
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   847
 * \ingroup testing
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   848
 *
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   849
 * \brief Test that an actual value is less than a limit and report if not.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   850
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   851
 * Check to see if the actual value found in a test case is less than the 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   852
 * limit value.  If the actual value is lesser nothing happens, but if the 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   853
 * check fails, an error is reported in a consistent way.  EXPECT* macros do 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   854
 * not return if an error is detected.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   855
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   856
 * The message is interpreted as a stream.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   857
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   858
 * \param actual Expression for the actual value found during the test.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   859
 * \param limit Expression for the limit value of the test.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   860
 * \param msg Message that is output if the test does not pass.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   861
 */
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   862
#define NS_TEST_EXPECT_MSG_LT(actual, limit, msg) \
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   863
  NS_TEST_EXPECT_MSG_LT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   864
10884
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   865
/**
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   866
 * \ingroup testing
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   867
 *
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   868
 * \brief Test that an actual value is less than or equal to a limit and report
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   869
 *        if not.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   870
 *
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   871
 * Check to see if the actual value found in a test case is less than or equal to
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   872
 * the limit value.  If the actual value is lesser or equal nothing happens, but
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   873
 * if the check fails, an error is reported in a consistent way.  EXPECT* macros
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   874
 * do not return if an error is detected.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   875
 *
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   876
 * The message is interpreted as a stream.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   877
 *
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   878
 * \param actual Expression for the actual value found during the test.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   879
 * \param limit Expression for the limit value of the test.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   880
 * \param msg Message that is output if the test does not pass.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   881
 */
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   882
#define NS_TEST_EXPECT_MSG_LT_OR_EQ(actual, limit, msg) \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   883
  NS_TEST_EXPECT_MSG_LT_OR_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   884
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   885
// ===========================================================================
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   886
// Test for greater than relation
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   887
// ===========================================================================
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   888
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   889
/**
11046
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
   890
 * \ingroup testingimpl
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   891
 * \brief Test that an actual value is greater than a limit and report and abort
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   892
 * if not.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   893
 */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   894
#define NS_TEST_ASSERT_MSG_GT_INTERNAL(actual, limit, msg, file, line)  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   895
  do {                                                                  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   896
    if (!((actual) > (limit)))                                          \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   897
      {                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   898
        ASSERT_ON_FAILURE;                                              \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   899
        std::ostringstream msgStream;                                   \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   900
        msgStream << msg;                                               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   901
        std::ostringstream actualStream;                                \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   902
        actualStream << actual;                                         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   903
        std::ostringstream limitStream;                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   904
        limitStream << limit;                                           \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   905
        ReportTestFailure (std::string (#actual) + " (actual) > " +         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   906
                       std::string (#limit) + " (limit)",               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   907
                       actualStream.str (), limitStream.str (),         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   908
                       msgStream.str (), file, line);                   \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   909
        CONTINUE_ON_FAILURE;                                            \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   910
      }                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   911
  } while (false)
9
2c31ae7c94db import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   912
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   913
/**
11046
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
   914
 * \ingroup testingimpl
10884
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   915
 * \brief Test that an actual value is greater than or equal to a limit and
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   916
 * report and abort if not.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   917
 */
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   918
#define NS_TEST_ASSERT_MSG_GT_OR_EQ_INTERNAL(actual, limit, msg, file, line)  \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   919
  do {                                                                  \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   920
    if (!((actual) >= (limit)))                                          \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   921
      {                                                                 \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   922
        ASSERT_ON_FAILURE;                                              \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   923
        std::ostringstream msgStream;                                   \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   924
        msgStream << msg;                                               \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   925
        std::ostringstream actualStream;                                \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   926
        actualStream << actual;                                         \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   927
        std::ostringstream limitStream;                                 \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   928
        limitStream << limit;                                           \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   929
        ReportTestFailure (std::string (#actual) + " (actual) > " +         \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   930
                       std::string (#limit) + " (limit)",               \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   931
                       actualStream.str (), limitStream.str (),         \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   932
                       msgStream.str (), file, line);                   \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   933
        CONTINUE_ON_FAILURE;                                            \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   934
      }                                                                 \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   935
  } while (false)
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   936
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   937
/**
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   938
 * \ingroup testing
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   939
 *
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   940
 * \brief Test that an actual value is greater than a limit and report and abort
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   941
 * if not.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   942
 *
6273
8d70de29d514 spell check, mostly in comments.
Andrey Mazo <mazo@iitp.ru>
parents: 6204
diff changeset
   943
 * Check to see if the actual value found in a test case is greater than the 
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   944
 * limit value.  If the actual value is greater nothing happens, but if the 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   945
 * check fails, an error is reported in a consistent way and the execution
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   946
 * of the current test case is aborted.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   947
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   948
 * The message is interpreted as a stream.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   949
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   950
 * \param actual Expression for the actual value found during the test.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   951
 * \param limit Expression for the limit value of the test.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   952
 * \param msg Message that is output if the test does not pass.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   953
 */
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   954
#define NS_TEST_ASSERT_MSG_GT(actual, limit, msg) \
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   955
  NS_TEST_ASSERT_MSG_GT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   956
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   957
/**
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   958
 * \ingroup testing
10884
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   959
 *
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   960
 * \brief Test that an actual value is greater than or equal to a limit and
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   961
 * report and abort if not.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   962
 *
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   963
 * Check to see if the actual value found in a test case is greater than or
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   964
 * equal to the limit value.  If the actual value is greater nothing happens, but
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   965
 * if the check fails, an error is reported in a consistent way and the execution
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   966
 * of the current test case is aborted.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   967
 *
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   968
 * The message is interpreted as a stream.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   969
 *
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   970
 * \param actual Expression for the actual value found during the test.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   971
 * \param limit Expression for the limit value of the test.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   972
 * \param msg Message that is output if the test does not pass.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   973
 */
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   974
#define NS_TEST_ASSERT_MSG_GT_OR_EQ(actual, limit, msg) \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   975
  NS_TEST_ASSERT_MSG_GT_OR_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   976
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
   977
/**
11046
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
   978
 * \ingroup testingimpl
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
   979
 * \brief Test that an actual value is greater than a limit and report if not.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   980
 * 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   981
 * Required to avoid use of return statement which allows use in methods 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   982
 * (callbacks) returning void.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
   983
 */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   984
#define NS_TEST_EXPECT_MSG_GT_INTERNAL(actual, limit, msg, file, line)  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   985
  do {                                                                  \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   986
    if (!((actual) > (limit)))                                          \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   987
      {                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   988
        ASSERT_ON_FAILURE;                                               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   989
        std::ostringstream msgStream;                                   \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   990
        msgStream << msg;                                               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   991
        std::ostringstream actualStream;                                \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   992
        actualStream << actual;                                         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   993
        std::ostringstream limitStream;                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   994
        limitStream << limit;                                           \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   995
        ReportTestFailure (std::string (#actual) + " (actual) > " +      \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   996
                       std::string (#limit) + " (limit)",               \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   997
                       actualStream.str (), limitStream.str (),         \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   998
                       msgStream.str (), file, line);                   \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
   999
      }                                                                 \
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1000
  } while (false)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1001
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1002
/**
11046
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
  1003
 * \ingroup testingimpl
11181
01d91bb3dfb8 fix small typo
Tom Henderson <tomh@tomh.org>
parents: 11046
diff changeset
  1004
 * \brief Test that an actual value is greater than or equal to limit and
10884
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1005
 * report if not.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1006
 *
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1007
 * Required to avoid use of return statement which allows use in methods
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1008
 * (callbacks) returning void.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1009
 */
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1010
#define NS_TEST_EXPECT_MSG_GT_OR_EQ_INTERNAL(actual, limit, msg, file, line)  \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1011
  do {                                                                  \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1012
    if (!((actual) >= (limit)))                                          \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1013
      {                                                                 \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1014
        ASSERT_ON_FAILURE;                                               \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1015
        std::ostringstream msgStream;                                   \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1016
        msgStream << msg;                                               \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1017
        std::ostringstream actualStream;                                \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1018
        actualStream << actual;                                         \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1019
        std::ostringstream limitStream;                                 \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1020
        limitStream << limit;                                           \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1021
        ReportTestFailure (std::string (#actual) + " (actual) > " +      \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1022
                       std::string (#limit) + " (limit)",               \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1023
                       actualStream.str (), limitStream.str (),         \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1024
                       msgStream.str (), file, line);                   \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1025
      }                                                                 \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1026
  } while (false)
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1027
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1028
/**
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1029
 * \ingroup testing
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
  1030
 *
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1031
 * \brief Test that an actual value is greater than a limit and report if not.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1032
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1033
 * Check to see if the actual value found in a test case is greater than the 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1034
 * limit value.  If the actual value is greater nothing happens, but if the 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1035
 * check fails, an error is reported in a consistent way.  EXPECT* macros do 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1036
 * not return if an error is detected.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1037
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1038
 * The message is interpreted as a stream.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1039
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1040
 * \param actual Expression for the actual value found during the test.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1041
 * \param limit Expression for the limit value of the test.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1042
 * \param msg Message that is output if the test does not pass.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1043
 */
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1044
#define NS_TEST_EXPECT_MSG_GT(actual, limit, msg) \
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1045
  NS_TEST_EXPECT_MSG_GT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1046
10884
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1047
/**
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1048
 * \ingroup testing
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1049
 *
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1050
 * \brief Test that an actual value is greater than or equal to limit and report
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1051
 * if not.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1052
 *
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1053
 * Check to see if the actual value found in a test case is greater than or
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1054
 * equal to the limit value.  If the actual value is greater nothing happens,
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1055
 * but if the check fails, an error is reported in a consistent way.  EXPECT* macros do
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1056
 * not return if an error is detected.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1057
 *
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1058
 * The message is interpreted as a stream.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1059
 *
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1060
 * \param actual Expression for the actual value found during the test.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1061
 * \param limit Expression for the limit value of the test.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1062
 * \param msg Message that is output if the test does not pass.
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1063
 */
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1064
#define NS_TEST_EXPECT_MSG_GT_OR_EQ(actual, limit, msg) \
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1065
  NS_TEST_EXPECT_MSG_GT_OR_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
78099d73b2f4 GT_OR_EQ and LT_OR_EQ macros for testing
Natale Patriciello <natale.patriciello@gmail.com>
parents: 10654
diff changeset
  1066
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1067
namespace ns3 {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1068
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1069
/**
11046
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
  1070
 * \ingroup testing
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1071
 * \brief Compare two double precision floating point numbers and declare them
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1072
 * equal if they are within some epsilon of each other.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1073
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1074
 * Approximate comparison of floating point numbers near equality is trickier
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1075
 * than one may expect and is well-discussed in the literature.  Basic 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1076
 * strategies revolve around a suggestion by Knuth to compare the floating 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1077
 * point numbers as binary integers, supplying a maximum difference between
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1078
 * them .  This max difference is specified in Units in the Last Place (ulps)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1079
 * or a floating point epsilon.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1080
 *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1081
 * This routine is based on the GNU Scientific Library function gsl_fcmp.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1082
 * 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1083
 * \param a The first of double precision floating point numbers to compare
5225
9c612cb88d6b Doxygenize.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5185
diff changeset
  1084
 * \param b The second of double precision floating point numbers to compare
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1085
 * \param epsilon The second of double precision floating point numberss to compare
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1086
 * \returns Returns true if the doubles are equal to a precision defined by epsilon
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1087
 */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1088
bool TestDoubleIsEqual (const double a, const double b, 
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1089
                        const double epsilon = std::numeric_limits<double>::epsilon ());
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1090
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1091
class TestRunnerImpl;
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1092
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1093
/**
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
  1094
 * \ingroup testing
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
  1095
 *
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1096
 * \brief encapsulates test code
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1097
 *
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1098
 * To allow a new test to be run within the ns-3 test framework, users
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1099
 * need to create subclasses of this base class, override the DoRun method,
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1100
 * and use the NS_TEST_* macros within DoRun.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1101
 */
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1102
class TestCase
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1103
{
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1104
public:
9265
0455e96a3cca Allow three speeds of test cases to be skipped
Mitch Watrous <watrous@u.washington.edu>
parents: 9257
diff changeset
  1105
  /**
0455e96a3cca Allow three speeds of test cases to be skipped
Mitch Watrous <watrous@u.washington.edu>
parents: 9257
diff changeset
  1106
   * \enum TestDuration
0455e96a3cca Allow three speeds of test cases to be skipped
Mitch Watrous <watrous@u.washington.edu>
parents: 9257
diff changeset
  1107
   * \brief How long the test takes to execute.
0455e96a3cca Allow three speeds of test cases to be skipped
Mitch Watrous <watrous@u.washington.edu>
parents: 9257
diff changeset
  1108
   */
0455e96a3cca Allow three speeds of test cases to be skipped
Mitch Watrous <watrous@u.washington.edu>
parents: 9257
diff changeset
  1109
  enum TestDuration {
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1110
    QUICK         = 1,  //!< Fast test.
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1111
    EXTENSIVE     = 2,  //!< Medium length test.
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1112
    TAKES_FOREVER = 3   //!< Very long running test.
9265
0455e96a3cca Allow three speeds of test cases to be skipped
Mitch Watrous <watrous@u.washington.edu>
parents: 9257
diff changeset
  1113
  };
0455e96a3cca Allow three speeds of test cases to be skipped
Mitch Watrous <watrous@u.washington.edu>
parents: 9257
diff changeset
  1114
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1115
  /**
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1116
   *  Destructor
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1117
   */
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1118
  virtual ~TestCase ();
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1119
10587
804b073ef2fd Enable tests to get the name of the parent suite.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9967
diff changeset
  1120
  /**
804b073ef2fd Enable tests to get the name of the parent suite.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9967
diff changeset
  1121
   * \return name of this test
804b073ef2fd Enable tests to get the name of the parent suite.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9967
diff changeset
  1122
   */
804b073ef2fd Enable tests to get the name of the parent suite.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9967
diff changeset
  1123
  std::string GetName (void) const;  
804b073ef2fd Enable tests to get the name of the parent suite.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9967
diff changeset
  1124
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1125
protected:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1126
  /**
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1127
   * \param name the name of the new TestCase created
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1128
   */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1129
  TestCase (std::string name);
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1130
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1131
  /**
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1132
   * \brief Add an individual child TestCase to this test suite.
9266
d26408b17360 bug 1563: get rid of default argument value in AddTestCase
Nicola Baldo <nbaldo@cttc.es>
parents: 9265
diff changeset
  1133
   *
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1134
   * \param testCase Pointer to the TestCase object to be added.
9265
0455e96a3cca Allow three speeds of test cases to be skipped
Mitch Watrous <watrous@u.washington.edu>
parents: 9257
diff changeset
  1135
   * \param duration Amount of time this test takes to execute.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1136
   */
9266
d26408b17360 bug 1563: get rid of default argument value in AddTestCase
Nicola Baldo <nbaldo@cttc.es>
parents: 9265
diff changeset
  1137
  void AddTestCase (TestCase *testCase, enum TestDuration duration);
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1138
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1139
  /**
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1140
   * \param directory the directory where the test data is located
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1141
   *
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1142
   * In general, this method is invoked as SetDataDir (NS_TEST_SOURCEDIR);
7409
ef4818bb81bc bug 1232: NS_TEST_SOURCEDIR does not handle test subdirectories
Tom Henderson <tomh@tomh.org>
parents: 7379
diff changeset
  1143
   * However, if a module contains a test directory with subdirectories
ef4818bb81bc bug 1232: NS_TEST_SOURCEDIR does not handle test subdirectories
Tom Henderson <tomh@tomh.org>
parents: 7379
diff changeset
  1144
   * (e.g. src/mesh/test), and the test data (e.g. pcap traces) is located
ef4818bb81bc bug 1232: NS_TEST_SOURCEDIR does not handle test subdirectories
Tom Henderson <tomh@tomh.org>
parents: 7379
diff changeset
  1145
   * in one of these subdirectories, then the variable NS_TEST_SOURCEDIR 
ef4818bb81bc bug 1232: NS_TEST_SOURCEDIR does not handle test subdirectories
Tom Henderson <tomh@tomh.org>
parents: 7379
diff changeset
  1146
   * may not work and the user may want to explicitly pass in a 
ef4818bb81bc bug 1232: NS_TEST_SOURCEDIR does not handle test subdirectories
Tom Henderson <tomh@tomh.org>
parents: 7379
diff changeset
  1147
   * directory string.
ef4818bb81bc bug 1232: NS_TEST_SOURCEDIR does not handle test subdirectories
Tom Henderson <tomh@tomh.org>
parents: 7379
diff changeset
  1148
   *
ef4818bb81bc bug 1232: NS_TEST_SOURCEDIR does not handle test subdirectories
Tom Henderson <tomh@tomh.org>
parents: 7379
diff changeset
  1149
   * Note that NS_TEST_SOURCEDIR is set in src/wscript for each module
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1150
   */
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1151
  void SetDataDir (std::string directory);
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1152
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1153
  /**
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1154
   * \return true if the tests have failed, false otherwise.
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1155
   */
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1156
  bool IsStatusFailure (void) const;
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1157
  /**
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1158
   * \return true if the tests have succeeded, false otherwise.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1159
   */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1160
  bool IsStatusSuccess (void) const;
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1161
8920
518fce9abcf9 Bug 1476: TestCase::GetName () should not be private
Mitch Watrous <watrous@u.washington.edu>
parents: 7745
diff changeset
  1162
  /**
10587
804b073ef2fd Enable tests to get the name of the parent suite.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9967
diff changeset
  1163
   * \return a pointer to the parent of this test
8920
518fce9abcf9 Bug 1476: TestCase::GetName () should not be private
Mitch Watrous <watrous@u.washington.edu>
parents: 7745
diff changeset
  1164
   */
10587
804b073ef2fd Enable tests to get the name of the parent suite.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9967
diff changeset
  1165
  TestCase * GetParent () const;
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1166
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1167
  /**
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
  1168
   * @{
11046
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
  1169
   * \internal
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
  1170
   * The methods below are used only by test macros and should not
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
  1171
   * be used by normal users.
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
  1172
   */
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
  1173
  /**
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1174
   * Log the failure of this TestCase.
11046
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
  1175
   *
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
  1176
   * \param cond The test condition.
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
  1177
   * \param actual Actual value of the test.
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
  1178
   * \param limit Expected value of the test.
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
  1179
   * \param message Message indicating the type of failure.
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
  1180
   * \param file The file where the test failed.
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
  1181
   * \param line The line number in \p file where the test failed.
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1182
   */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1183
  void ReportTestFailure (std::string cond, std::string actual, 
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1184
                      std::string limit, std::string message, 
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1185
                      std::string file, int32_t line);
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1186
  /**
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1187
   * \return should we assert on failure, per the TestSuite configuration
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1188
   */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1189
  bool MustAssertOnFailure (void) const;
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1190
  /**
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1191
   * \return should we continue on failure, per the TestSuite configuration
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1192
   */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1193
  bool MustContinueOnFailure (void) const;
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1194
  /**
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1195
   * \param filename the bare (no path) file name
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1196
   * \return the full path to filename in the data directory
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1197
   */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1198
  std::string CreateDataDirFilename (std::string filename);
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1199
  /**
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1200
   * \param filename the bare (no path) file name
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1201
   * \return the full path to filename in the temporary directory.
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1202
   *  If the TestRunner is invoked with "--update-data", this will be
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1203
   *  the data directory instead.
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1204
   */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1205
  std::string CreateTempDirFilename (std::string filename);
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
  1206
  /**@}*/
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1207
private:
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1208
  friend class TestRunnerImpl;
5324
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5239
diff changeset
  1209
0ba73cdd2a43 Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents: 5239
diff changeset
  1210
  /**
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1211
   * \brief Implementation to do any local setup required for this TestCase.
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1212
   *
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1213
   * Subclasses should override this method to perform any costly per-test setup
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1214
   * before DoRun is invoked.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1215
   */
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1216
  virtual void DoSetup (void);
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1217
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1218
  /**
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1219
   * \brief Implementation to actually run this TestCase.
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1220
   *
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1221
   * Subclasses should override this method to conduct their tests.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1222
   */
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
  1223
  virtual void DoRun (void) = 0;
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1224
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1225
  /**
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1226
   * \brief Implementation to do any local setup required for this TestCase.
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1227
   *
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1228
   * Subclasses should override this method to perform any costly per-test teardown
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1229
   */
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1230
  virtual void DoTeardown (void);
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1231
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1232
  /**
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1233
   * Private, to block copying
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1234
   */
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1235
  TestCase (TestCase& tc);
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1236
  /**
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1237
   * Private, to block copying
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1238
   */
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1239
  TestCase& operator= (TestCase& tc);
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1240
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1241
  // methods called by TestRunnerImpl
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1242
  /**
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1243
   * Actually run this TestCase
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
  1244
   *
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
  1245
   * \param runner The test runner implementation.
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1246
   */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1247
  void Run (TestRunnerImpl *runner);
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1248
  /**
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1249
   * \return the failure status of this TestCase and all it's children
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1250
   */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1251
  bool IsFailed (void) const;
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1252
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1253
  // Forward declaration is enough, since we only include a pointer here
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1254
  struct Result;
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1255
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1256
  TestCase *m_parent;                   //!< Pointer to my parent TestCase
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1257
  std::vector<TestCase *> m_children;   //!< Vector of my children
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1258
  std::string m_dataDir;                //!< My data directory
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1259
  TestRunnerImpl *m_runner;             //!< Pointer to the TestRunner
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1260
  struct Result *m_result;              //!< Results data
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1261
  std::string m_name;                   //!< TestCase name
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1262
  enum TestDuration m_duration;         //!< TestCase duration
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1263
};
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1264
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1265
/**
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
  1266
 * \ingroup testing
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
  1267
 *
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1268
 * \brief A suite of tests to run.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1269
 */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1270
class TestSuite : public TestCase
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1271
{
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1272
public:
5225
9c612cb88d6b Doxygenize.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5185
diff changeset
  1273
  /**
7600
57ba46094a0d fix various doxygen errors
Vedran Miletić <rivanvx@gmail.com>
parents: 7409
diff changeset
  1274
   * \enum Type
5225
9c612cb88d6b Doxygenize.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5185
diff changeset
  1275
   * \brief Type of test.
9c612cb88d6b Doxygenize.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5185
diff changeset
  1276
   */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1277
  enum Type {
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1278
    ALL = 0,    //!<
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1279
    BVT = 1,    //!< This test suite implements a Build Verification Test
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1280
    UNIT,       //!< This test suite implements a Unit Test
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1281
    SYSTEM,     //!< This test suite implements a System Test
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1282
    EXAMPLE,    //!< This test suite implements an Example Test
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1283
    PERFORMANCE //!< This test suite implements a Performance Test
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1284
  };
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1285
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1286
  /**
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1287
   * \brief Constuct a new test suite.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1288
   *
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1289
   * \param name The name of the test suite.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1290
   * \param type The TestType of the test suite (defaults to UNIT test).
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1291
   */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1292
  TestSuite (std::string name, Type type = UNIT);
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1293
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1294
  /**
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1295
   * \brief get the kind of test this test suite implements
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1296
   *
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1297
   * \returns the Type of the suite.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1298
   */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1299
  TestSuite::Type GetTestType (void);
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1300
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1301
private:
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6620
diff changeset
  1302
  virtual void DoRun (void);
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1303
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1304
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1305
  TestSuite::Type m_type;               //!< Type of this TestSuite
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1306
};
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1307
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1308
/**
11046
e62bccfbe56e [Doxygen] various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11045
diff changeset
  1309
 * \ingroup testingimpl
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
  1310
 *
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1311
 * \brief A runner to execute tests.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1312
 */
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1313
class TestRunner
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1314
{
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1315
public:
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1316
  /**
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1317
   * Run the requested suite of tests.
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1318
   *
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
  1319
   * \param argc number of elements in \pname{argv}
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
  1320
   * \param argv vector of command line arguments
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1321
   * \returns success status
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1322
   */
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7252
diff changeset
  1323
  static int Run (int argc, char *argv[]);
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1324
};
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1325
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1326
/**
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
  1327
 * \ingroup testing
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10591
diff changeset
  1328
 *
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1329
 * \brief A simple way to store test vectors (for stimulus or from responses)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1330
 */
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1331
template <typename T>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1332
class TestVectors
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1333
{
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1334
public:
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1335
  /**
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1336
   * Constructor
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1337
   */
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1338
  TestVectors ();
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1339
  /**
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1340
   * Virtual desctructor
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1341
   */
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1342
  virtual ~TestVectors ();
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1343
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1344
  /**
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1345
   * \param reserve the number of entries to reserve
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1346
   */
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1347
  void Reserve (uint32_t reserve);
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1348
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1349
  /**
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1350
   * \param vector the test vector to add
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1351
   * \returns the new test vector index
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1352
   */
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1353
  uint32_t Add (T vector);
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1354
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1355
  /**
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1356
   * \return the number of test vectors
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1357
   */
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1358
  uint32_t GetN (void) const;
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1359
  /**
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1360
   * Get the i'th test vector
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1361
   * \param i the requested vector index
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1362
   * \return the requested vector
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1363
   */
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1364
  T Get (uint32_t i) const;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1365
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1366
private:
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1367
  /**
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1368
   * Copy constructor, private to block copying
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1369
   */
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1370
  TestVectors (const TestVectors& tv);
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1371
  /**
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1372
   * Assignment, private to prevent copying
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1373
   */
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1374
  TestVectors& operator= (const TestVectors& tv);
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1375
  /**
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1376
   * Comparison (unimplemented?)
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1377
   */
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1378
  bool operator== (const TestVectors& tv) const;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1379
9967
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1380
  typedef std::vector<T> TestVector;    //!< Container type
ee6722b8afaa [Doxygen] use \internal
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9871
diff changeset
  1381
  TestVector m_vectors;                 //!< The list of test vectors
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1382
};
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1383
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1384
template <typename T>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1385
TestVectors<T>::TestVectors ()
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1386
  : m_vectors ()
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1387
{
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1388
}
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1389
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1390
template <typename T>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1391
void
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1392
TestVectors<T>::Reserve (uint32_t reserve)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1393
{
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1394
  m_vectors.reserve (reserve);
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1395
}
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1396
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1397
template <typename T>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1398
TestVectors<T>::~TestVectors ()
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1399
{
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1400
}
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1401
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1402
template <typename T>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1403
uint32_t
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1404
TestVectors<T>::Add (T vector)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1405
{
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1406
  uint32_t index = m_vectors.size ();
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1407
  m_vectors.push_back (vector);
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1408
  return index;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1409
}
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1410
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1411
template <typename T>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1412
uint32_t 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1413
TestVectors<T>::GetN (void) const
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1414
{
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1415
  return m_vectors.size ();
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1416
}
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1417
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1418
template <typename T>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1419
T
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1420
TestVectors<T>::Get (uint32_t i) const
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1421
{
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1422
  NS_ABORT_MSG_UNLESS (m_vectors.size () > i, "TestVectors::Get(): Bad index");
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1423
  return m_vectors[i];
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1424
}
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4678
diff changeset
  1425
5342
3c6109eec550 bug 675: kill old test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5324
diff changeset
  1426
} // namespace ns3 
9
2c31ae7c94db import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1427
5342
3c6109eec550 bug 675: kill old test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5324
diff changeset
  1428
#endif /* NS3_TEST_H */