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 ?");
82 Time ns = NanoSeconds (1);
85 "is 1ns really 1ns ?");
87 "is 1ps really 1ps ?");
89 "is 1fs really 1fs ?");
92 Time ten = NanoSeconds (10);
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.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
Simulation virtual time values and global simulation resolution.
Time TimeStep(uint64_t ts)
TimeTestSuite g_timeTestSuite
virtual void DoRun(void)
Implementation to actually run this TestCase.
TimeIntputOutputTestCase()
double GetSeconds(void) const
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...
TestCase * GetParent() const
int64_t GetInteger(void) const
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
int64_t GetNanoSeconds(void) const
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
TimeWithUnit As(const enum Unit unit) const
Attach a unit to a Time, to facilitate output in a specific unit.
void Check(const std::string &str)
std::string GetName(void) const
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoSetup(void)
Implementation to do any local setup required for this TestCase.
This test suite implements a Unit Test.