src/spectrum/test/spectrum-test.h
author Vedran Miletić <rivanvx@gmail.com>
Tue, 02 Aug 2011 17:42:33 -0400
changeset 7385 10beb0e53130
parent 7379 ff0d074f885a
child 11045 6024c150e4c8
permissions -rw-r--r--
standardize emacs c++ mode comments
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7385
10beb0e53130 standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents: 7379
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
7124
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
     2
/*
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
     3
 * Copyright (c) 2009 University of Washington
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
     4
 * Copyright (c) 2011 CTTC
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
     5
 *
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
     7
 * it under the terms of the GNU General Public License version 2 as
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
     8
 * published by the Free Software Foundation;
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
     9
 *
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    13
 * GNU General Public License for more details.
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    14
 *
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    16
 * along with this program; if not, write to the Free Software
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    18
 *
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    19
 * Author: Nicola Baldo <nbaldo@cttc.es>
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    20
 * part of the code copied from test.h
7124
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    21
 */
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    22
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    23
#include <ns3/test.h>
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    24
#include <ns3/spectrum-value.h>
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    25
7128
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    26
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    27
/**
7128
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    28
 * \brief Test if two SpectrumModel instances are equal within a given tolerance.
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    29
 *
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    30
 * This test compares component-by-component the two SpectrumModel
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    31
 * instances; if any pair of components differs by more than the given
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    32
 * tolerance, the test fails.
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    33
 *
7128
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    34
 * \param actual the actual value obtained by the simulator
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    35
 * \param expected the expected value obtained by off-line calculations
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    36
 * \param tol the tolerance
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    37
 * \param msg the message to print if the test fails
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    38
 *
7128
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    39
 */
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    40
#define NS_TEST_ASSERT_MSG_SPECTRUM_MODEL_EQ_TOL(actual, expected, tol, msg) \
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    41
  NS_TEST_ASSERT_MSG_SPECTRUM_MODEL_EQ_TOL_INTERNAL (actual, expected, tol, msg, __FILE__, __LINE__)
7128
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    42
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    43
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    44
/**
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    45
 * \internal
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    46
 */
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    47
#define NS_TEST_ASSERT_MSG_SPECTRUM_MODEL_EQ_TOL_INTERNAL(actual, expected, tol, msg, file, line) \
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    48
  do                                                                           \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    49
    {                                                                          \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    50
      Bands::const_iterator i = (actual).Begin ();                      \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    51
      Bands::const_iterator j = (expected).Begin ();                    \
7128
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    52
      uint32_t k = 0;                                                          \
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    53
      while (i != (actual).End () && j != (expected).End ())            \
7128
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    54
        {                                                                      \
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    55
          if ((i->fl > j->fl + (tol)) || (i->fl < j->fl - (tol))        \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    56
              || (i->fc > j->fc + (tol)) || (i->fc < j->fc - (tol))        \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    57
              || (i->fh > j->fh + (tol)) || (i->fh < j->fh - (tol)))       \
7128
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    58
            {                                           \
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
    59
              ASSERT_ON_FAILURE;                        \
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    60
              std::ostringstream indexStream;           \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    61
              indexStream << "[" << k << "]";           \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    62
              std::ostringstream msgStream;     \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    63
              msgStream << (msg);               \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    64
              std::ostringstream actualStream;  \
7128
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    65
              actualStream << i->fl << " <-- " << i->fc << " --> " << i->fh; \
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    66
              std::ostringstream expectedStream;        \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    67
              expectedStream << j->fl << " <-- " << j->fc << " --> " << j->fh;          \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    68
              ReportTestFailure (std::string (# actual) + indexStream.str () + " == " + std::string (# expected) + indexStream.str (),    \
7128
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    69
                                 actualStream.str (), expectedStream.str (), msgStream.str (), (file), (line)); \
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
    70
              CONTINUE_ON_FAILURE;                                      \
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    71
            }                   \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    72
          ++i;   \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    73
          ++j;   \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    74
          ++k;   \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    75
        }        \
7128
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    76
      if (i != (actual).End () || j != (expected).End ())       \
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    77
        { \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    78
          std::ostringstream msgStream;     \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    79
          msgStream << (msg);               \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    80
          std::ostringstream actualStream;  \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    81
          actualStream << (i != (actual).End ());   \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    82
          std::ostringstream expectedStream;        \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    83
          expectedStream <<  (j != (expected).End ());              \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    84
          ReportTestFailure ("Bands::iterator == End ()",                                  \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    85
                             actualStream.str (), expectedStream.str (), msgStream.str (), (file), (line)); \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    86
        } \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    87
    }            \
7128
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    88
  while (false); \
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    89
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
    90
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    91
/**
7124
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    92
 * \brief Test if two SpectrumValue instances are equal within a given tolerance.
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    93
 *
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    94
 * This test compares component-by-component the two SpectrumValue
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    95
 * instances; if any pair of components differs by more than the given
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    96
 * tolerance, the test fails.
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
    97
 *
7124
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    98
 * \param actual the actual value obtained by the simulator
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    99
 * \param expected the expected value obtained by off-line calculations
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   100
 * \param tol the tolerance
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   101
 * \param msg the message to print if the test fails
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   102
 *
7124
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   103
 */
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   104
#define NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL(actual, expected, tol, msg) \
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   105
  NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL_INTERNAL (actual, expected, tol, msg, __FILE__, __LINE__)
7124
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   106
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   107
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   108
/**
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   109
 * \internal
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   110
 */
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   111
#define NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL_INTERNAL(actual, expected, tol, msg, file, line) \
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   112
  do                                                                           \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   113
    {                                                                          \
7128
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
   114
      Values::const_iterator i = (actual).ConstValuesBegin ();          \
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
   115
      Values::const_iterator j = (expected).ConstValuesBegin ();        \
7124
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   116
      uint32_t k = 0;                                                          \
7128
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
   117
      while (i != (actual).ConstValuesEnd () && j != (expected).ConstValuesEnd ()) \
7124
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   118
        {                                                                      \
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   119
          if ((*i) > (*j) + (tol) || (*i) < (*j) - (tol))                      \
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   120
            {                                           \
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
   121
              ASSERT_ON_FAILURE;                        \
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   122
              std::ostringstream indexStream;           \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   123
              indexStream << "[" << k << "]";           \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   124
              std::ostringstream msgStream;     \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   125
              msgStream << msg;                 \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   126
              std::ostringstream actualStream;  \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   127
              actualStream << actual;           \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   128
              std::ostringstream expectedStream;        \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   129
              expectedStream << expected;               \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   130
              ReportTestFailure (std::string (# actual) + indexStream.str () + " == " + std::string (# expected) + indexStream.str (),    \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   131
                                 actualStream.str (), expectedStream.str (), msgStream.str (), file, line);     \
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
   132
              CONTINUE_ON_FAILURE;                                      \
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   133
            }                   \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   134
          ++i;   \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   135
          ++j;   \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   136
          ++k;   \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   137
        }        \
7128
8c0fd6c9fe14 refined spectrum-value test after bug 1122 fix
Nicola Baldo <nbaldo@cttc.es>
parents: 7124
diff changeset
   138
      if (i != (actual).ConstValuesEnd () || j != (expected).ConstValuesEnd ()) \
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   139
        { \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   140
          std::ostringstream msgStream;     \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   141
          msgStream << (msg);               \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   142
          std::ostringstream actualStream;  \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   143
          actualStream << (i != (actual).ConstValuesEnd ());        \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   144
          std::ostringstream expectedStream;        \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   145
          expectedStream <<  (j != (expected).ConstValuesEnd ());   \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   146
          ReportTestFailure ("Values::const_iterator == ConstValuesEnd ()",                                        \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   147
                             actualStream.str (), expectedStream.str (), msgStream.str (), (file), (line)); \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   148
        } \
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   149
    }            \
7124
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   150
  while (false); \
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   151
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   152
058f6ecace0c fixed Bug 1122 - spectrum-value test should check tolerance on a per-value basis
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   153
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 7129
diff changeset
   154