src/simulator/time.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu, 25 Feb 2010 14:17:21 +0100
changeset 6068 a2127017ecb4
parent 5367 d0b9a6e08e47
child 6177 2ae38db64dd1
permissions -rw-r--r--
merge with HEAD
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
150
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 144
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
25
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2005,2006 INRIA
680
0bbe0e4d73c6 add reference to Emmanuelle in Authors/Copyright
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 679
diff changeset
     4
 * Copyright (c) 2007 Emmanuelle Laprise
25
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 *
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * it under the terms of the GNU General Public License version 2 as
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 * published by the Free Software Foundation;
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 *
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 * GNU General Public License for more details.
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 *
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * along with this program; if not, write to the Free Software
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
 *
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
680
0bbe0e4d73c6 add reference to Emmanuelle in Authors/Copyright
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 679
diff changeset
    20
 * TimeStep support by Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
25
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
 */
679
0c4773ca0f29 avoid cyclic dependency between Simulator and Time code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 678
diff changeset
    22
#include "nstime.h"
372
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
    23
#include "ns3/fatal-error.h"
2577
5b41cb5c3fcf kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2447
diff changeset
    24
#include "ns3/global-value.h"
5b41cb5c3fcf kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2447
diff changeset
    25
#include "ns3/enum.h"
5b41cb5c3fcf kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2447
diff changeset
    26
#include "ns3/string.h"
2390
7e6dfae536cd add Value support to Time
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2170
diff changeset
    27
#include "ns3/object.h"
2577
5b41cb5c3fcf kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2447
diff changeset
    28
#include "ns3/config.h"
679
0c4773ca0f29 avoid cyclic dependency between Simulator and Time code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 678
diff changeset
    29
#include <math.h>
25
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
namespace ns3 {
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
    33
namespace TimeStepPrecision {
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
    34
4210
da9be6abb1b2 bug 486: patches for icc compilation.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4045
diff changeset
    35
static const uint64_t MS_FACTOR = (uint64_t)1000;
da9be6abb1b2 bug 486: patches for icc compilation.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4045
diff changeset
    36
static const uint64_t US_FACTOR = (uint64_t)1000000;
da9be6abb1b2 bug 486: patches for icc compilation.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4045
diff changeset
    37
static const uint64_t NS_FACTOR = (uint64_t)1000000 * (uint64_t)1000;
da9be6abb1b2 bug 486: patches for icc compilation.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4045
diff changeset
    38
static const uint64_t PS_FACTOR = (uint64_t)1000000 * (uint64_t)1000000;
da9be6abb1b2 bug 486: patches for icc compilation.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4045
diff changeset
    39
static const uint64_t FS_FACTOR = (uint64_t)1000000 * (uint64_t)1000000 * (uint64_t)1000;
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
    40
static uint64_t g_tsPrecFactor = NS_FACTOR;
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
    41
2577
5b41cb5c3fcf kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2447
diff changeset
    42
static GlobalValue g_precisionDefaultValue ("TimeStepPrecision", 
5b41cb5c3fcf kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2447
diff changeset
    43
                                            "The time unit of the internal 64 bit integer time.",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2953
diff changeset
    44
                                            EnumValue (NS),
2577
5b41cb5c3fcf kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2447
diff changeset
    45
                                            MakeEnumChecker (NS, "NS",
5b41cb5c3fcf kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2447
diff changeset
    46
                                                             S, "S",
5b41cb5c3fcf kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2447
diff changeset
    47
                                                             MS, "MS",
5b41cb5c3fcf kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2447
diff changeset
    48
                                                             US, "US",
5b41cb5c3fcf kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2447
diff changeset
    49
                                                             PS, "PS",
5b41cb5c3fcf kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2447
diff changeset
    50
                                                             FS, "FS")
5b41cb5c3fcf kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2447
diff changeset
    51
                                            );
684
333ec02c9cc9 add DefaultValue support for TimeStepPrecision
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 680
diff changeset
    52
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
    53
precision_t
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
    54
Get (void)
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
    55
{
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2953
diff changeset
    56
  EnumValue v;
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2953
diff changeset
    57
  g_precisionDefaultValue.GetValue (v);
2577
5b41cb5c3fcf kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2447
diff changeset
    58
  return (precision_t) v.Get ();
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
    59
}
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
    60
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
    61
void 
684
333ec02c9cc9 add DefaultValue support for TimeStepPrecision
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 680
diff changeset
    62
Set (precision_t precision)
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
    63
{
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2953
diff changeset
    64
  g_precisionDefaultValue.SetValue (EnumValue (precision));
684
333ec02c9cc9 add DefaultValue support for TimeStepPrecision
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 680
diff changeset
    65
  g_tsPrecFactor = (uint64_t)pow(10, precision);
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
    66
}
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
    67
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
    68
} // namespace TimeStepPrecision
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
    69
372
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
    70
TimeUnit<1>::TimeUnit(const std::string& s)
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
    71
{
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
    72
  std::string::size_type n = s.find_first_not_of("0123456789.");
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
    73
  if (n != std::string::npos)
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
    74
  { // Found non-numeric
3365
6409d2460601 bug 245: build failure with gcc 4.3.x
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3188
diff changeset
    75
    std::istringstream iss;
6409d2460601 bug 245: build failure with gcc 4.3.x
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3188
diff changeset
    76
    iss.str (s.substr(0, n));
6409d2460601 bug 245: build failure with gcc 4.3.x
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3188
diff changeset
    77
    double r;
6409d2460601 bug 245: build failure with gcc 4.3.x
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3188
diff changeset
    78
    iss >> r;
372
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
    79
    std::string trailer = s.substr(n, std::string::npos);
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
    80
    if (trailer == std::string("s"))
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
    81
    {
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
    82
      m_data = HighPrecision (r * TimeStepPrecision::g_tsPrecFactor);
372
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
    83
      return;
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
    84
    }
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
    85
    if (trailer == std::string("ms"))
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
    86
    {
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
    87
      m_data = HighPrecision ((int64_t)(r * (TimeStepPrecision::g_tsPrecFactor/pow(10,3))), 
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
    88
                              false);
372
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
    89
      return;
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
    90
    }
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
    91
    if (trailer == std::string("us"))
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
    92
    {
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
    93
      m_data = HighPrecision ((int64_t)(r * (TimeStepPrecision::g_tsPrecFactor/pow(10,6))), 
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
    94
                              false);
372
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
    95
      return;
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
    96
    }
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
    97
    if (trailer == std::string("ns"))
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
    98
    {
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
    99
      m_data = HighPrecision ((int64_t)(r * (TimeStepPrecision::g_tsPrecFactor/pow(10,9))), 
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   100
                              false);
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   101
      return;
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   102
    }
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   103
    if (trailer == std::string("ps"))
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   104
    {
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
   105
      m_data = HighPrecision ((int64_t)(r * (TimeStepPrecision::g_tsPrecFactor/pow(10,12))), 
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   106
                              false);
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   107
      return;
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   108
    }
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   109
    if (trailer == std::string("fs"))
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   110
    {
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
   111
      m_data = HighPrecision ((int64_t)(r * (TimeStepPrecision::g_tsPrecFactor/pow(10,15))), 
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   112
                              false);
372
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
   113
      return;
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
   114
    }
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
   115
    NS_FATAL_ERROR("Can't Parse Time "<<s);
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
   116
  }
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
   117
  //else
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
   118
  //they didn't provide units, assume seconds
3365
6409d2460601 bug 245: build failure with gcc 4.3.x
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3188
diff changeset
   119
  std::istringstream iss;
6409d2460601 bug 245: build failure with gcc 4.3.x
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3188
diff changeset
   120
  iss. str (s);
6409d2460601 bug 245: build failure with gcc 4.3.x
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3188
diff changeset
   121
  double v;
6409d2460601 bug 245: build failure with gcc 4.3.x
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3188
diff changeset
   122
  iss >> v;
6409d2460601 bug 245: build failure with gcc 4.3.x
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3188
diff changeset
   123
  m_data = HighPrecision (v * TimeStepPrecision::g_tsPrecFactor);
372
c242f488ef0b Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents: 367
diff changeset
   124
}
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   125
143
552ff26b4224 new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   126
double 
339
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 229
diff changeset
   127
TimeUnit<1>::GetSeconds (void) const
36
e622fb7a8262 use ns as internal time and export time as ns.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 25
diff changeset
   128
{
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   129
  double timeValue = GetHighPrecision ().GetDouble ();
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
   130
  return timeValue/TimeStepPrecision::g_tsPrecFactor;
25
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   131
}
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   132
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   133
int64_t
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   134
TimeUnit<1>::ConvertToUnits (int64_t timeValue, uint64_t unitFactor) const
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   135
{
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   136
  uint64_t precFactor;
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   137
  // In order to avoid conversion to double, precFactor can't be less 1
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
   138
  if (TimeStepPrecision::g_tsPrecFactor < unitFactor)
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   139
    {
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
   140
      precFactor = unitFactor / TimeStepPrecision::g_tsPrecFactor;
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   141
      timeValue = timeValue * precFactor;
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   142
    }
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   143
  else
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   144
    {
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
   145
      precFactor = TimeStepPrecision::g_tsPrecFactor / unitFactor;
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   146
      timeValue = timeValue / precFactor;
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   147
    }
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   148
  return timeValue;
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   149
}
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   150
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   151
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   152
int64_t 
339
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 229
diff changeset
   153
TimeUnit<1>::GetMilliSeconds (void) const
36
e622fb7a8262 use ns as internal time and export time as ns.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 25
diff changeset
   154
{
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   155
  int64_t ts = GetTimeStep();
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
   156
  int64_t ms = ConvertToUnits(ts, TimeStepPrecision::MS_FACTOR);
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   157
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   158
  return ms;
143
552ff26b4224 new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   159
}
144
f07f6fb0f660 fix Time::ApproximateTo* return type
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 143
diff changeset
   160
int64_t 
339
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 229
diff changeset
   161
TimeUnit<1>::GetMicroSeconds (void) const
143
552ff26b4224 new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   162
{
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   163
  int64_t ts = GetTimeStep();
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
   164
  int64_t us = ConvertToUnits(ts, TimeStepPrecision::US_FACTOR);
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   165
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   166
  return us;
36
e622fb7a8262 use ns as internal time and export time as ns.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 25
diff changeset
   167
}
144
f07f6fb0f660 fix Time::ApproximateTo* return type
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 143
diff changeset
   168
int64_t 
339
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 229
diff changeset
   169
TimeUnit<1>::GetNanoSeconds (void) const
25
9b3bb088c560 first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   170
{
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   171
  int64_t ts = GetTimeStep();
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
   172
  int64_t ns = ConvertToUnits(ts, TimeStepPrecision::NS_FACTOR);
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   173
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   174
  return ns;
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   175
}
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   176
int64_t 
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   177
TimeUnit<1>::GetPicoSeconds (void) const
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   178
{
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   179
  int64_t ts = GetTimeStep();
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
   180
  int64_t ps = ConvertToUnits(ts, TimeStepPrecision::PS_FACTOR);
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   181
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   182
  return ps;
36
e622fb7a8262 use ns as internal time and export time as ns.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 25
diff changeset
   183
}
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   184
int64_t 
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   185
TimeUnit<1>::GetFemtoSeconds (void) const
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   186
{
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   187
  int64_t ts = GetTimeStep();
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
   188
  int64_t fs = ConvertToUnits(ts, TimeStepPrecision::FS_FACTOR);
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   189
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   190
  return fs;
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   191
}
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   192
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   193
/**
684
333ec02c9cc9 add DefaultValue support for TimeStepPrecision
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 680
diff changeset
   194
 * This returns the value with the precision returned by TimeStepPrecision::Get
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   195
 */
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   196
int64_t
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   197
TimeUnit<1>::GetTimeStep (void) const
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   198
{
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   199
  int64_t timeValue = GetHighPrecision ().GetInteger ();
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   200
  return timeValue;
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   201
}
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   202
143
552ff26b4224 new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   203
209
8b343b9727d7 fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 199
diff changeset
   204
std::ostream& 
2409
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   205
operator<< (std::ostream& os, const Time & time)
209
8b343b9727d7 fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 199
diff changeset
   206
{
911
de8102a51fbf append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 684
diff changeset
   207
  std::string unit;
de8102a51fbf append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 684
diff changeset
   208
  switch (TimeStepPrecision::Get ()) {
de8102a51fbf append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 684
diff changeset
   209
  case TimeStepPrecision::S:
de8102a51fbf append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 684
diff changeset
   210
    unit = "s";
de8102a51fbf append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 684
diff changeset
   211
    break;
de8102a51fbf append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 684
diff changeset
   212
  case TimeStepPrecision::MS:
de8102a51fbf append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 684
diff changeset
   213
    unit = "ms";
de8102a51fbf append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 684
diff changeset
   214
    break;
de8102a51fbf append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 684
diff changeset
   215
  case TimeStepPrecision::US:
de8102a51fbf append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 684
diff changeset
   216
    unit = "us";
de8102a51fbf append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 684
diff changeset
   217
    break;
de8102a51fbf append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 684
diff changeset
   218
  case TimeStepPrecision::NS:
de8102a51fbf append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 684
diff changeset
   219
    unit = "ns";
de8102a51fbf append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 684
diff changeset
   220
    break;
de8102a51fbf append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 684
diff changeset
   221
  case TimeStepPrecision::PS:
de8102a51fbf append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 684
diff changeset
   222
    unit = "ps";
de8102a51fbf append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 684
diff changeset
   223
    break;
de8102a51fbf append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 684
diff changeset
   224
  case TimeStepPrecision::FS:
de8102a51fbf append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 684
diff changeset
   225
    unit = "fs";
de8102a51fbf append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 684
diff changeset
   226
    break;
de8102a51fbf append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 684
diff changeset
   227
  }
de8102a51fbf append correct unit when printing Time objects
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 684
diff changeset
   228
  os << time.GetTimeStep () << unit;
209
8b343b9727d7 fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 199
diff changeset
   229
  return os;
8b343b9727d7 fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 199
diff changeset
   230
}
2409
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   231
std::istream& operator>> (std::istream& is, Time & time)
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   232
{
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   233
  std::string value;
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   234
  is >> value;
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   235
  std::string::size_type n = value.find_first_not_of("0123456789.");
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   236
  if (n == std::string::npos)
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   237
    {
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   238
      is.setstate (std::ios_base::failbit);
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   239
      return is;
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   240
    }
2953
db884a56c5c1 -1 cuts the trailing s if the time postfix is longer than 1 char.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2947
diff changeset
   241
  std::string trailer = value.substr(n, value.size ()-n);
2409
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   242
  std::istringstream iss;
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   243
  iss.str (value.substr(0, n));
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   244
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   245
  if (trailer == std::string("s"))
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   246
    {
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   247
      double v;
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   248
      iss >> v;
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   249
      time = Seconds (v);
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   250
      return is;
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   251
    }
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   252
  uint64_t integer;
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   253
  iss >> integer;
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   254
  if (is.bad () || is.fail ())
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   255
    {
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   256
      is.setstate (std::ios_base::failbit);
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   257
    }
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   258
  else if (trailer == std::string("ms"))
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   259
    {
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   260
      time = MilliSeconds (integer);
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   261
    }
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   262
  else if (trailer == std::string("us"))
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   263
    {
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   264
      time = MicroSeconds (integer);
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   265
    }
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   266
  else if (trailer == std::string("ns"))
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   267
    {
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   268
      time = NanoSeconds (integer);
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   269
    }
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   270
  else if (trailer == std::string("ps"))
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   271
    {
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   272
      time = PicoSeconds (integer);
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   273
    }
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   274
  else if (trailer == std::string("fs"))
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   275
    {
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   276
      time = FemtoSeconds (integer);
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   277
    }
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   278
  else
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   279
    {
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   280
      is.setstate (std::ios_base::failbit);
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   281
    }
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   282
  return is;
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2396
diff changeset
   283
}
143
552ff26b4224 new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   284
209
8b343b9727d7 fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 199
diff changeset
   285
Time Seconds (double seconds)
8b343b9727d7 fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 199
diff changeset
   286
{
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
   287
  double d_sec = seconds * TimeStepPrecision::g_tsPrecFactor;
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   288
  return Time (HighPrecision (d_sec));
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   289
  //  return Time (HighPrecision ((int64_t)d_sec, false));
209
8b343b9727d7 fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 199
diff changeset
   290
}
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   291
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   292
uint64_t
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   293
TimeUnit<1>::UnitsToTimestep (uint64_t unitValue, 
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   294
                              uint64_t unitFactor)
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   295
{
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   296
  uint64_t precFactor;
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   297
  // In order to avoid conversion to double, precFactor can't be less 1
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
   298
  if (TimeStepPrecision::g_tsPrecFactor < unitFactor)
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   299
    {
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
   300
      precFactor = unitFactor / TimeStepPrecision::g_tsPrecFactor;
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   301
      unitValue = unitValue / precFactor;
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   302
    }
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   303
  else
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   304
    {
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
   305
      precFactor = TimeStepPrecision::g_tsPrecFactor / unitFactor;
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   306
      unitValue = unitValue * precFactor;
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   307
    }
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   308
  return unitValue;
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   309
}
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   310
2447
eee344085a96 convert to new helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2436
diff changeset
   311
ATTRIBUTE_VALUE_IMPLEMENT (Time);
eee344085a96 convert to new helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2436
diff changeset
   312
ATTRIBUTE_CHECKER_IMPLEMENT (Time);
2427
9245ec163111 split checker from ParamSpec.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2409
diff changeset
   313
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   314
Time MilliSeconds (uint64_t ms)
209
8b343b9727d7 fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 199
diff changeset
   315
{
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
   316
  uint64_t ts = TimeUnit<1>::UnitsToTimestep(ms, TimeStepPrecision::MS_FACTOR);
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   317
  return TimeStep(ts);
209
8b343b9727d7 fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 199
diff changeset
   318
}
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   319
209
8b343b9727d7 fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 199
diff changeset
   320
Time MicroSeconds (uint64_t us)
8b343b9727d7 fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 199
diff changeset
   321
{
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
   322
  uint64_t ts = TimeUnit<1>::UnitsToTimestep(us, TimeStepPrecision::US_FACTOR);
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   323
  return TimeStep(ts);
209
8b343b9727d7 fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 199
diff changeset
   324
}
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   325
209
8b343b9727d7 fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 199
diff changeset
   326
Time NanoSeconds (uint64_t ns)
8b343b9727d7 fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 199
diff changeset
   327
{
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
   328
  uint64_t ts = TimeUnit<1>::UnitsToTimestep(ns, TimeStepPrecision::NS_FACTOR);
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   329
  return TimeStep(ts);
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   330
}
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   331
Time PicoSeconds (uint64_t ps)
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   332
{
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
   333
  uint64_t ts = TimeUnit<1>::UnitsToTimestep(ps, TimeStepPrecision::PS_FACTOR);
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   334
  return TimeStep(ts);
209
8b343b9727d7 fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 199
diff changeset
   335
}
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   336
Time FemtoSeconds (uint64_t fs)
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   337
{
677
de21f6a2435e namespace the precision values properly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 676
diff changeset
   338
  uint64_t ts = TimeUnit<1>::UnitsToTimestep(fs, TimeStepPrecision::FS_FACTOR);
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   339
  return TimeStep(ts);
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   340
}
2390
7e6dfae536cd add Value support to Time
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2170
diff changeset
   341
7e6dfae536cd add Value support to Time
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2170
diff changeset
   342
676
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   343
/*
0cf407300fa6 Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents: 675
diff changeset
   344
 * The timestep value passed to this function must be of the precision
684
333ec02c9cc9 add DefaultValue support for TimeStepPrecision
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 680
diff changeset
   345
 * of TimeStepPrecision::Get
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   346
 */
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   347
Time TimeStep (uint64_t ts)
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   348
{
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   349
  return Time (HighPrecision (ts, false));
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   350
}
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   351
339
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 229
diff changeset
   352
TimeUnit<0>::TimeUnit (double scalar)
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 229
diff changeset
   353
  : m_data (HighPrecision (scalar))
143
552ff26b4224 new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   354
{}
156
3b1563e95ea7 new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 151
diff changeset
   355
158
47af319de4b8 implement Scalar::GetDouble
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 157
diff changeset
   356
double
339
0ce0402e419f make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 229
diff changeset
   357
TimeUnit<0>::GetDouble (void) const
158
47af319de4b8 implement Scalar::GetDouble
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 157
diff changeset
   358
{
47af319de4b8 implement Scalar::GetDouble
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 157
diff changeset
   359
  return GetHighPrecision ().GetDouble ();
47af319de4b8 implement Scalar::GetDouble
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 157
diff changeset
   360
}
47af319de4b8 implement Scalar::GetDouble
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 157
diff changeset
   361
2390
7e6dfae536cd add Value support to Time
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2170
diff changeset
   362
} // namespace ns3
143
552ff26b4224 new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   363
157
19ffb62f521e add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 156
diff changeset
   364
#include "ns3/test.h"
19ffb62f521e add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 156
diff changeset
   365
19ffb62f521e add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 156
diff changeset
   366
namespace ns3 {
19ffb62f521e add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 156
diff changeset
   367
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   368
#define PRECISION(mult) (pow(10,-((double)(ns3::TimeStepPrecision::Get ())))*mult)
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   369
#define ASSERT_MSG_EQ(a,b,mult,msg)                                     \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   370
  NS_TEST_ASSERT_MSG_EQ(((a)<((b)-PRECISION(mult)) || (a)>((b)+PRECISION(mult))),false, \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   371
                        msg << " Values are not equal within requested precision range: " << \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   372
                        (a) << "!=" << (b) << " ~ " << PRECISION(mult))
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   373
#define ASSERT_MSG_EQ_INT(a,b,mult,msg) \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   374
  ASSERT_MSG_EQ(((int64_t)(a)),((int64_t)(b)),mult,msg)
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   375
#define ASSERT_EQ(a,b)                          \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   376
  ASSERT_MSG_EQ(a,b,1,"")
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   377
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   378
class OldTimeTestCase : public TestCase
157
19ffb62f521e add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 156
diff changeset
   379
{
19ffb62f521e add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 156
diff changeset
   380
public:
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   381
  OldTimeTestCase();
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   382
  virtual bool DoRun (void);
157
19ffb62f521e add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 156
diff changeset
   383
};
19ffb62f521e add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 156
diff changeset
   384
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   385
OldTimeTestCase::OldTimeTestCase()
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   386
  : TestCase("Sanity check of common time operations")
157
19ffb62f521e add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 156
diff changeset
   387
{}
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   388
bool 
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   389
OldTimeTestCase::DoRun (void)
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   390
{  
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   391
  NS_TEST_ASSERT_MSG_EQ(TimeStepPrecision::Get(), 
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   392
                        TimeStepPrecision::NS,
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   393
                        "Invalid precision mode");
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   394
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   395
  Time t0 = Seconds (10.0);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   396
  ASSERT_EQ(t0.GetSeconds(), 10.0);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   397
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   398
  Time t1 = Seconds (11.0);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   399
  ASSERT_EQ(t1.GetSeconds(), 11.0);
176
74494759f122 more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 170
diff changeset
   400
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   401
  t0 = Seconds (1.5);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   402
  ASSERT_EQ(t0.GetSeconds(), 1.5);
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   403
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   404
  t0 = Seconds (-1.5);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   405
  ASSERT_EQ(t0.GetSeconds(), -1.5);
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   406
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   407
  t0 = MilliSeconds ((uint64_t)10.0);
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   408
  ASSERT_EQ(t0.GetSeconds(), 0.01);
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   409
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   410
  t1 = MilliSeconds ((uint64_t)11.0);
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   411
  ASSERT_EQ(t1.GetSeconds(), 0.011);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   412
176
74494759f122 more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 170
diff changeset
   413
74494759f122 more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 170
diff changeset
   414
  Time t2, t3;
74494759f122 more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 170
diff changeset
   415
74494759f122 more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 170
diff changeset
   416
  t2 = t1 - t0;
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   417
  NS_TEST_ASSERT_MSG_EQ(t2.IsStrictlyPositive (),true, "Variable should be positive");
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   418
  ASSERT_EQ(t2.GetSeconds(), t1.GetSeconds()-t0.GetSeconds());
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   419
176
74494759f122 more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 170
diff changeset
   420
  t2 = t1 - t1;
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   421
  NS_TEST_ASSERT_MSG_EQ(t2.IsZero (),true, "Variable should be zero");
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   422
  ASSERT_EQ(t2.GetSeconds(), t1.GetSeconds()-t1.GetSeconds());
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   423
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   424
  t2 = t0 - t1;
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   425
  NS_TEST_ASSERT_MSG_EQ(t2.IsStrictlyNegative (),true, "Variable should be negative");
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   426
  ASSERT_EQ(t2.GetSeconds(), t0.GetSeconds()-t1.GetSeconds());
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   427
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   428
  Time tmp = MilliSeconds (0);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   429
  NS_TEST_ASSERT_MSG_EQ((MilliSeconds (0) == NanoSeconds(0)), true, "Zero is not Zero ?");
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   430
  NS_TEST_ASSERT_MSG_EQ((MilliSeconds (0) > NanoSeconds(0)), false, "Zero is bigger than Zero ?");
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   431
  NS_TEST_ASSERT_MSG_EQ((MilliSeconds (0) < NanoSeconds(0)), false, "Zero is smaller than Zero ?");
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   432
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   433
  Time t4 = Seconds (10.0) * Scalar (1.5);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   434
  ASSERT_EQ(t4.GetSeconds(), 15.0);
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   435
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   436
  Time t5 = NanoSeconds (10) * Scalar (1.5);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   437
  ASSERT_EQ(t5.GetNanoSeconds(), 15.0);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   438
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   439
  Time t6 = Seconds (10.0) * Scalar (15) / Scalar (10);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   440
  ASSERT_EQ(t6.GetSeconds (), 15.0);
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   441
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   442
  Time t7 = NanoSeconds (10) * Scalar (15) / Scalar (10);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   443
  ASSERT_EQ(t7.GetNanoSeconds (), 15.0);
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   444
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   445
  ASSERT_EQ((t1 + t2).GetSeconds (), t1.GetSeconds()+t2.GetSeconds());
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   446
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   447
  ASSERT_EQ((t1 / t2).GetDouble (), t1.GetSeconds()/t2.GetSeconds());
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   448
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   449
  return false;
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   450
}
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   451
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   452
class OperationsTimeTestCase : public TestCase
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   453
{
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   454
public:
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   455
  OperationsTimeTestCase();
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   456
  virtual bool DoRun(void);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   457
};
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   458
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   459
OperationsTimeTestCase::OperationsTimeTestCase()
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   460
  : TestCase ("Check the +, -, * and / operators for the TimeUnit<1>")
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   461
{}
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   462
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   463
bool
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   464
OperationsTimeTestCase::DoRun(void)
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   465
{
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   466
  // What happens if you set these values ?
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   467
  //  t0 = Seconds ((uint64_t)10.0);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   468
  //  t1 = Seconds ((uint64_t)11.0);
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   469
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   470
  Time t0 = MilliSeconds(10);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   471
  Time t1 = MilliSeconds(11);
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   472
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   473
  ASSERT_EQ((t0-t1).GetSeconds(),
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   474
            (t0.GetSeconds()-t1.GetSeconds()));
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   475
  ASSERT_EQ(((t0-t1) * t0 / t0).GetSeconds(),
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   476
            ((t0.GetSeconds()-t1.GetSeconds()) * t0.GetSeconds () / t0.GetSeconds ()));
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   477
  ASSERT_EQ(((t0-t1) * t0 / t1).GetSeconds(),
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   478
            ((t0.GetSeconds()-t1.GetSeconds()) * t0.GetSeconds () / t1.GetSeconds ()));
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   479
  ASSERT_EQ((t0 * (t0-t1) / t1).GetSeconds(),
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   480
            (t0.GetSeconds () * (t0.GetSeconds()-t1.GetSeconds()) / t1.GetSeconds ()));
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   481
  ASSERT_EQ((t0 * t1 / (t0-t1)).GetSeconds(),
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   482
            (t0.GetSeconds () * t1.GetSeconds() / (t0.GetSeconds()-t1.GetSeconds())));
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   483
  ASSERT_EQ((t0 * (t1 / (t0-t1))).GetSeconds(),
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   484
            (t0.GetSeconds () * (t1.GetSeconds() / (t0.GetSeconds()-t1.GetSeconds()))));
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   485
  ASSERT_EQ(((t0 * t1) / (t0-t1)).GetSeconds(),
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   486
            ((t0.GetSeconds () * t1.GetSeconds()) / (t0.GetSeconds()-t1.GetSeconds())));
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   487
  ASSERT_EQ((t0 / t1 * (t0-t1)).GetSeconds(),
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   488
            (t0.GetSeconds () / t1.GetSeconds() * (t0.GetSeconds()-t1.GetSeconds())));
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   489
  ASSERT_EQ(((t0 / t1) * (t0-t1)).GetSeconds(),
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   490
              (t0.GetSeconds () / t1.GetSeconds()) * (t0.GetSeconds()-t1.GetSeconds()));
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   491
  ASSERT_EQ((t0 * Scalar(10.0)).GetSeconds (), (t0.GetSeconds () * 10.0));
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   492
  ASSERT_EQ((Scalar(10.0) * t0).GetSeconds (), (10.0 * t0.GetSeconds ()));
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   493
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   494
  // Note: we need to multiply by 1e9 because GetSeconds is multiplying
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   495
  ASSERT_EQ(((t0/(t1*(t0-t1))).GetHighPrecision().GetDouble() * 1e9),
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   496
             (t0.GetSeconds()/(t1.GetSeconds()*(t0.GetSeconds()-t1.GetSeconds()))));
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   497
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   498
  ASSERT_EQ((t0/t1).GetDouble(),(t0.GetSeconds()/t1.GetSeconds()));
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   499
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   500
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   501
  ASSERT_EQ((t0 * t1 / ((t0-t1) * t0)).GetDouble (),
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   502
            (t0.GetSeconds () * t1.GetSeconds () / ((t0.GetSeconds () - t1.GetSeconds()) * t0.GetSeconds ())));
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   503
  return false;
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   504
}
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   505
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   506
class TimeStepTestCase : public TestCase
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   507
{
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   508
public:
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   509
  TimeStepTestCase ();
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   510
  virtual bool DoRun (void);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   511
};
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   512
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   513
TimeStepTestCase::TimeStepTestCase ()
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   514
  : TestCase("Check boundaries of TimeStep")
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   515
{}
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   516
bool
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   517
TimeStepTestCase::DoRun (void)
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   518
{
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   519
  Time tooBig = TimeStep (0x8000000000000000LL);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   520
  NS_TEST_ASSERT_MSG_EQ (tooBig.IsNegative (), true, "Is not negative ?");
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   521
  tooBig = TimeStep (0xffffffffffffffffLL);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   522
  NS_TEST_ASSERT_MSG_EQ (tooBig.IsNegative (), true, "Is not negative ?");
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   523
  tooBig = TimeStep (0x7fffffffffffffffLL);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   524
  NS_TEST_ASSERT_MSG_EQ (tooBig.IsPositive (), true, "Is not negative ?");
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   525
  tooBig += TimeStep (1);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   526
  NS_TEST_ASSERT_MSG_EQ (tooBig.IsNegative (), true, "Is not negative ?");
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   527
  return false;
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   528
}
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   529
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   530
class GlobalPrecisionTestCase : public TestCase
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   531
{
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   532
public:
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   533
  GlobalPrecisionTestCase ();
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   534
  virtual bool DoRun (void);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   535
  virtual void DoTeardown (void);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   536
};
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   537
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   538
GlobalPrecisionTestCase::GlobalPrecisionTestCase ()
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   539
  : TestCase ("Check that global value actually changes the underlying precision")
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   540
{}
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   541
#define CHECK_PRECISION(prec) \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   542
  Config::SetGlobal ("TimeStepPrecision", StringValue (#prec)); \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   543
  NS_TEST_ASSERT_MSG_EQ(TimeStepPrecision::Get(), TimeStepPrecision::prec, "Could not set precision " << #prec)
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   544
bool 
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   545
GlobalPrecisionTestCase::DoRun (void)
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   546
{
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   547
  CHECK_PRECISION(S);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   548
  CHECK_PRECISION(MS);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   549
  CHECK_PRECISION(US);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   550
  CHECK_PRECISION(NS);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   551
  CHECK_PRECISION(PS);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   552
  CHECK_PRECISION(FS);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   553
  return false;
157
19ffb62f521e add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 156
diff changeset
   554
}
19ffb62f521e add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 156
diff changeset
   555
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   556
void 
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   557
GlobalPrecisionTestCase::DoTeardown (void)
4045
8b99076fcd96 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3365
diff changeset
   558
{
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   559
  TimeStepPrecision::Set (TimeStepPrecision::NS);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   560
}
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   561
5367
d0b9a6e08e47 disable test to avoid compiler failures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5304
diff changeset
   562
#if 0
d0b9a6e08e47 disable test to avoid compiler failures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5304
diff changeset
   563
// disable this test because it triggers crazy 
d0b9a6e08e47 disable test to avoid compiler failures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5304
diff changeset
   564
// compiler behavior (ICE+unbounded memory usage)
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   565
class ConversionTestCase : public TestCase
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   566
{
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   567
public:
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   568
  ConversionTestCase ();
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   569
  virtual bool DoRun (void);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   570
  virtual void DoTeardown (void);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   571
};
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   572
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   573
ConversionTestCase::ConversionTestCase ()
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   574
  : TestCase ("Check crazy time conversions")
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   575
{}
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   576
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   577
void ConversionTestCase::DoTeardown (void)
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   578
{
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   579
  TimeStepPrecision::Set (TimeStepPrecision::NS);
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   580
}
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   581
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   582
#define CHECK_CONVERSIONS(tmp)                                          \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   583
  do {                                                                  \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   584
    double val = tmp;                                                   \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   585
    Time t_sec = Seconds(val);                                          \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   586
    ASSERT_MSG_EQ(t_sec.GetSeconds(), val*1e0, 1e0, "conv sec s");          \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   587
    ASSERT_MSG_EQ_INT(t_sec.GetMilliSeconds(), val*1e3, 1e3, "conv sec ms"); \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   588
    ASSERT_MSG_EQ_INT(t_sec.GetMicroSeconds(), val*1e6, 1e6, "conv sec us"); \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   589
    ASSERT_MSG_EQ_INT(t_sec.GetNanoSeconds(), val*1e9, 1e9, "conv sec ns"); \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   590
    ASSERT_MSG_EQ_INT(t_sec.GetPicoSeconds(), val*1e12, 1e12, "conv sec ps"); \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   591
    ASSERT_MSG_EQ_INT(t_sec.GetFemtoSeconds(), val*1e15, 1e15, "conv sec fs"); \
5304
32f5dd35314a Add explicit typecasts for gcc-4.1.2
Andrey Mazo <mazo@iitp.ru>
parents: 5284
diff changeset
   592
    uint64_t int_val = (uint64_t)val;                                  \
32f5dd35314a Add explicit typecasts for gcc-4.1.2
Andrey Mazo <mazo@iitp.ru>
parents: 5284
diff changeset
   593
    Time t_ms = MilliSeconds(int_val);                                 \
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   594
    ASSERT_MSG_EQ(t_ms.GetSeconds(), val*1e-3, 1e0, "conv ms s");       \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   595
    ASSERT_MSG_EQ_INT(t_ms.GetMilliSeconds(), val*1e0, 1e3, "conv ms ms");     \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   596
    ASSERT_MSG_EQ_INT(t_ms.GetMicroSeconds(), val*1e3, 1e6, "conv ms us"); \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   597
    ASSERT_MSG_EQ_INT(t_ms.GetNanoSeconds(), val*1e6, 1e9, "conv ms ns");  \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   598
    ASSERT_MSG_EQ_INT(t_ms.GetPicoSeconds(), val*1e9, 1e12, "conv ms fs"); \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   599
    ASSERT_MSG_EQ_INT(t_ms.GetFemtoSeconds(), val*1e12, 1e15, "conv ms ps"); \
5304
32f5dd35314a Add explicit typecasts for gcc-4.1.2
Andrey Mazo <mazo@iitp.ru>
parents: 5284
diff changeset
   600
    Time t_us = MicroSeconds(int_val);                                     \
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   601
    ASSERT_MSG_EQ(t_us.GetSeconds(), val*1e-6, 1e0, "conv us s");       \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   602
    ASSERT_MSG_EQ_INT(t_us.GetMilliSeconds(), val*1e-3, 1e3, "conv us ms"); \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   603
    ASSERT_MSG_EQ_INT(t_us.GetMicroSeconds(), val*1e0, 1e6, "conv us us");     \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   604
    ASSERT_MSG_EQ_INT(t_us.GetNanoSeconds(), val*1e3, 1e9, "conv us ns");  \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   605
    ASSERT_MSG_EQ_INT(t_us.GetPicoSeconds(), val*1e6, 1e12, "conv us ps"); \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   606
    ASSERT_MSG_EQ_INT(t_us.GetFemtoSeconds(), val*1e9, 1e15, "conv us fs"); \
5304
32f5dd35314a Add explicit typecasts for gcc-4.1.2
Andrey Mazo <mazo@iitp.ru>
parents: 5284
diff changeset
   607
    Time t_ns = NanoSeconds(int_val);                                      \
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   608
    ASSERT_MSG_EQ(t_ns.GetSeconds(), val*1e-9, 1e0, "conv ns s");       \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   609
    ASSERT_MSG_EQ_INT(t_ns.GetMilliSeconds(), val*1e-6, 1e3, "conv ns ms"); \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   610
    ASSERT_MSG_EQ_INT(t_ns.GetMicroSeconds(), val*1e-3, 1e6, "conv ns us"); \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   611
    ASSERT_MSG_EQ_INT(t_ns.GetNanoSeconds(), val*1e0, 1e9, "conv ns ns");      \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   612
    ASSERT_MSG_EQ_INT(t_ns.GetPicoSeconds(), val*1e3, 1e12, "conv ns ps"); \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   613
    ASSERT_MSG_EQ_INT(t_ns.GetFemtoSeconds(), val*1e6, 1e15, "conv ns fs"); \
5304
32f5dd35314a Add explicit typecasts for gcc-4.1.2
Andrey Mazo <mazo@iitp.ru>
parents: 5284
diff changeset
   614
    Time t_ps = PicoSeconds(int_val);                                      \
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   615
    ASSERT_MSG_EQ(t_ps.GetSeconds(), val*1e-12, 1e0, "conv ps s");      \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   616
    ASSERT_MSG_EQ_INT(t_ps.GetMilliSeconds(), val*1e-9, 1e3, "conv ps ms"); \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   617
    ASSERT_MSG_EQ_INT(t_ps.GetMicroSeconds(), val*1e-6, 1e6, "conv ps us"); \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   618
    ASSERT_MSG_EQ_INT(t_ps.GetNanoSeconds(), val*1e-3, 1e9, "conv ps ns");  \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   619
    ASSERT_MSG_EQ_INT(t_ps.GetPicoSeconds(), val*1e0, 1e12, "conv ps ps");     \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   620
    ASSERT_MSG_EQ_INT(t_ps.GetFemtoSeconds(), val*1e3, 1e15, "conv ps fs"); \
5304
32f5dd35314a Add explicit typecasts for gcc-4.1.2
Andrey Mazo <mazo@iitp.ru>
parents: 5284
diff changeset
   621
    Time t_fs = FemtoSeconds(int_val);                                     \
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   622
    ASSERT_MSG_EQ(t_fs.GetSeconds(), val*1e-15, 1e0, "conv fs sec");    \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   623
    ASSERT_MSG_EQ_INT(t_fs.GetMilliSeconds(), val*1e-12, 1e3, "conv fs ms"); \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   624
    ASSERT_MSG_EQ_INT(t_fs.GetMicroSeconds(), val*1e-9, 1e6, "conv fs us"); \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   625
    ASSERT_MSG_EQ_INT(t_fs.GetNanoSeconds(), val*1e-6, 1e9, "conv fs ns");  \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   626
    ASSERT_MSG_EQ_INT(t_fs.GetPicoSeconds(), val*1e-3, 1e12, "conv fs ps"); \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   627
    ASSERT_MSG_EQ_INT(t_fs.GetFemtoSeconds(), val*1e0, 1e15, "conv fs fs");    \
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   628
  } while (false)
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   629
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   630
bool
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   631
ConversionTestCase::DoRun (void)
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   632
{
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   633
  CHECK_CONVERSIONS(5);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   634
  CHECK_CONVERSIONS(0);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   635
  CHECK_CONVERSIONS(783);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   636
  CHECK_CONVERSIONS(1132);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   637
  // triggers overflow
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   638
  // XXX
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   639
  // CHECK_CONVERSIONS(3341039);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   640
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   641
  TimeStepPrecision::Set (TimeStepPrecision::US);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   642
  CHECK_CONVERSIONS(7);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   643
  CHECK_CONVERSIONS(546);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   644
  CHECK_CONVERSIONS(6231);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   645
  // triggers overflow
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   646
  // XXX
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   647
  // CHECK_CONVERSIONS(1234639);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   648
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   649
  TimeStepPrecision::Set (TimeStepPrecision::MS);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   650
  CHECK_CONVERSIONS(3);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   651
  CHECK_CONVERSIONS(134);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   652
  CHECK_CONVERSIONS(2341);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   653
  // triggers overflow
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   654
  // XXX
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   655
  // CHECK_CONVERSIONS(8956239);
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   656
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   657
  TimeStepPrecision::Set (TimeStepPrecision::NS);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   658
  CHECK_CONVERSIONS(4);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   659
  CHECK_CONVERSIONS(342);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   660
  CHECK_CONVERSIONS(1327);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   661
  // triggers overflow
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   662
  // XXX
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   663
  // CHECK_CONVERSIONS(5439627);
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   664
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   665
  TimeStepPrecision::Set (TimeStepPrecision::PS);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   666
  CHECK_CONVERSIONS(4);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   667
  CHECK_CONVERSIONS(342);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   668
  CHECK_CONVERSIONS(1327);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   669
  // triggers overflow
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   670
  // XXX
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   671
  // CHECK_CONVERSIONS(5439627);
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   672
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   673
  TimeStepPrecision::Set (TimeStepPrecision::NS);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   674
  CHECK_CONVERSIONS(12);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   675
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   676
  TimeStepPrecision::Set (TimeStepPrecision::S);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   677
  CHECK_CONVERSIONS(7);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   678
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   679
  TimeStepPrecision::Set (TimeStepPrecision::FS);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   680
  CHECK_CONVERSIONS(5);
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   681
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   682
  return false;
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   683
}
5367
d0b9a6e08e47 disable test to avoid compiler failures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5304
diff changeset
   684
#endif
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   685
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   686
static class TimeTestSuite : public TestSuite
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   687
{
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   688
public:
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   689
  TimeTestSuite()
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   690
    : TestSuite("time", UNIT)
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   691
  {
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   692
    AddTestCase(new OldTimeTestCase());
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   693
    AddTestCase(new OperationsTimeTestCase());
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   694
    AddTestCase(new TimeStepTestCase());
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   695
    AddTestCase(new GlobalPrecisionTestCase());
5367
d0b9a6e08e47 disable test to avoid compiler failures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5304
diff changeset
   696
    //AddTestCase(new ConversionTestCase());
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   697
  }
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   698
} g_timeTestSuite;
675
a5878de7d71c The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents: 372
diff changeset
   699
5283
1a805e0bf415 bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4396
diff changeset
   700
} // namespace ns3