28 #include "ns3/nstime.h"    29 #include "ns3/int64x64.h"    39   virtual void DoSetup (
void);
    40   virtual void DoRun (
void);
    41   virtual void DoTeardown (
void);
    45   : 
TestCase (
"Sanity check of common time operations")
    78                          "is 1ms really 1ms ?");
    80                          "is 1us really 1us ?");
    85                          "is 1ns really 1ns ?");
    87                          "is 1ps really 1ps ?");
    89                          "is 1fs really 1fs ?");
    94   Time::SetResolution (Time::PS);
    97                          "change resolution to PS");
   111   virtual void DoRun (
void);
   116   : 
TestCase (
"Checks times that have plus or minus signs")
   128   Time timePositive          (
"+1000.0");
   129   Time timePositiveWithUnits (
"+1000.0ms");
   131   Time timeNegative          (
"-1000.0");
   132   Time timeNegativeWithUnits (
"-1000.0ms");
   137                              "Positive time not parsed correctly.");
   142                              "Positive time with units not parsed correctly.");
   147                              "Negative time not parsed correctly.");
   152                              "Negative time with units not parsed correctly.");
   166   virtual void DoRun (
void);
   167   void Check (
const std::string & str);
   171   : 
TestCase (
"Input,output from,to strings")
   178   std::stringstream ss (str);
   182   bool pass = (str == ss.str ()); 
   185             << (pass ? 
"pass " : 
"FAIL ")
   186             << 
"\"" << str << 
"\"";
   189       std::cout << 
", got " << ss.str ();
   191   std::cout << std::endl;
   197   std::cout << std::endl;
   210   Time t (3.141592654e9);  
   213             << 
"example: raw:   " << t
   217             << std::fixed << std::setprecision (9)
   218             << 
"example: in s:  " << t.
As (Time::S)
   222             << std::setprecision (6)
   223             << 
"example: in ms: " << t.
As (Time::MS)
   230   std::cout << std::endl;
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
Simulation virtual time values and global simulation resolution. 
int64_t GetInteger(void) const
Get the raw time value, in the current resolution unit. 
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase. 
TimeTestSuite g_timeTestSuite
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit. 
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit. 
TimeWithUnit As(const enum Unit unit) const
Attach a unit to a Time, to facilitate output in a specific unit. 
Time PicoSeconds(uint64_t value)
Construct a Time in the indicated unit. 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
Time Years(double value)
Construct a Time in the indicated unit. 
virtual void DoSetup(void)
Implementation to do any local setup required for this TestCase. 
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite. 
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit. 
virtual void DoSetup(void)
Implementation to do any local setup required for this TestCase. 
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not. 
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit. 
TestCase * GetParent() const
Get the parent of this TestCsse. 
Time Hours(double value)
Construct a Time in the indicated unit. 
Time TimeStep(uint64_t ts)
Time Minutes(double value)
Construct a Time in the indicated unit. 
std::string GetName(void) const
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase. 
Time Seconds(double value)
Construct a Time in the indicated unit. 
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit. 
Time Days(double value)
Construct a Time in the indicated unit. 
Time FemtoSeconds(uint64_t value)
Construct a Time in the indicated unit. 
This test suite implements a Unit Test.