22 #include "ns3/nstime.h"
32 virtual void DoSetup (
void);
33 virtual void DoRun (
void);
34 virtual void DoTeardown (
void);
39 TimeSimpleTestCase::TimeSimpleTestCase (
enum Time::Unit resolution)
40 :
TestCase (
"Sanity check of common time operations"),
41 m_resolution (resolution)
48 m_originalResolution = Time::GetResolution ();
54 Time::SetResolution (m_resolution);
55 NS_TEST_ASSERT_MSG_EQ_TOL (
Seconds (1.0).GetSeconds (), 1.0, TimeStep (1).GetSeconds (),
57 NS_TEST_ASSERT_MSG_EQ_TOL (
Seconds (10.0).GetSeconds (), 10.0, TimeStep (1).GetSeconds (),
59 NS_TEST_ASSERT_MSG_EQ (
MilliSeconds (1).GetMilliSeconds (), 1,
60 "is 1ms really 1ms ?");
61 NS_TEST_ASSERT_MSG_EQ (
MicroSeconds (1).GetMicroSeconds (), 1,
62 "is 1us really 1us ?");
66 NS_TEST_ASSERT_MSG_EQ (
NanoSeconds (1).GetNanoSeconds (), 1,
67 "is 1ns really 1ns ?");
68 NS_TEST_ASSERT_MSG_EQ (
PicoSeconds (1).GetPicoSeconds (), 1,
69 "is 1ps really 1ps ?");
70 NS_TEST_ASSERT_MSG_EQ (
FemtoSeconds (1).GetFemtoSeconds (), 1,
71 "is 1fs really 1fs ?");
78 Time::SetResolution (m_originalResolution);
87 virtual void DoRun (
void);
91 TimesWithSignsTestCase::TimesWithSignsTestCase ()
92 :
TestCase (
"Checks times that have plus or minus signs")
104 Time timePositive (
"+1000.0");
105 Time timePositiveWithUnits (
"+1000.0ms");
107 Time timeNegative (
"-1000.0");
108 Time timeNegativeWithUnits (
"-1000.0ms");
110 NS_TEST_ASSERT_MSG_EQ_TOL (timePositive.
GetSeconds (),
113 "Positive time not parsed correctly.");
115 NS_TEST_ASSERT_MSG_EQ_TOL (timePositiveWithUnits.
GetSeconds (),
118 "Positive time with units not parsed correctly.");
120 NS_TEST_ASSERT_MSG_EQ_TOL (timeNegative.
GetSeconds (),
123 "Negative time not parsed correctly.");
125 NS_TEST_ASSERT_MSG_EQ_TOL (timeNegativeWithUnits.
GetSeconds (),
128 "Negative time with units not parsed correctly.");
Time NanoSeconds(uint64_t ns)
create ns3::Time instances in units of nanoseconds.
virtual void DoRun(void)
Implementation to actually run this test case.
virtual void DoTeardown(void)
Implementation to do any local setup required for this test case.
virtual void DoRun(void)
Implementation to actually run this test case.
TestSuite(std::string name, Type type=UNIT)
Constuct a new test suite.
Time PicoSeconds(uint64_t ps)
create ns3::Time instances in units of picoseconds.
double GetSeconds(void) const
virtual void DoSetup(void)
Implementation to do any local setup required for this test case.
Time FemtoSeconds(uint64_t fs)
create ns3::Time instances in units of femtoseconds.
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite.
int64_t GetNanoSeconds(void) const
virtual void DoTeardown(void)
Implementation to do any local setup required for this test case.
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
Time MilliSeconds(uint64_t ms)
create ns3::Time instances in units of milliseconds.
virtual void DoSetup(void)
Implementation to do any local setup required for this test case.
Time MicroSeconds(uint64_t us)
create ns3::Time instances in units of microseconds.