1 #include "ns3/int64x64.h"
10 virtual void DoRun (
void);
11 void CheckFrac (int64_t hi, uint64_t lo);
17 int64x64_t tmp = int64x64_t (hi,lo);
19 "High part does not match");
21 "Low part does not match");
25 :
TestCase (
"Check that we can manipulate the high and low part of every number")
42 virtual void DoRun (
void);
43 void CheckString (std::string str, int64_t hi, uint64_t lo);
46 :
TestCase (
"Check that we parse Int64x64 numbers as strings")
52 std::istringstream iss;
74 CheckString (
"1.08446744073709551615", 1, 8446744073709551615LL);
75 CheckString (
"-1.08446744073709551615", -1, 8446744073709551615LL);
82 virtual void DoRun (
void);
86 :
TestCase (
"Check that we can roundtrip Int64x64 numbers as strings")
92 std::istringstream iss;
96 std::ostringstream oss;
112 #define CHECK_EXPECTED(a,b) \
113 NS_TEST_ASSERT_MSG_EQ ((a).GetHigh (),b,"Arithmetic failure: " << ((a).GetHigh ()) << "!=" << (b))
122 virtual void DoRun (
void);
126 :
TestCase (
"Check basic arithmetic operations")
180 virtual void DoRun (
void);
184 :
TestCase (
"Test case for bug 455")
190 int64x64_t a = int64x64_t (0.1);
191 a /= int64x64_t (1.25);
193 a = int64x64_t (0.5);
196 a = int64x64_t (-0.5);
199 a = int64x64_t (-0.5);
202 a = int64x64_t (0.5);
203 a *= int64x64_t (-5);
214 virtual void DoRun (
void);
218 :
TestCase (
"Test case for bug 863")
224 int64x64_t a = int64x64_t (0.9);
227 a = int64x64_t (0.5);
228 a /= int64x64_t (0.5);
230 a = int64x64_t (-0.5);
232 a /= int64x64_t (0.5);
234 a = int64x64_t (0.5);
235 a /= int64x64_t (-0.5);
237 a = int64x64_t (-0.5);
238 a /= int64x64_t (-0.5);
246 virtual void DoRun (
void);
249 :
TestCase (
"Check basic compare operations")
268 virtual void DoRun (
void);
272 :
TestCase (
"Test case for invertion")
279 #define TEST(factor) \
282 a = int64x64_t::Invert (factor); \
283 int64x64_t b = V (factor); \
285 NS_TEST_ASSERT_MSG_EQ (b.GetHigh (), 1, \
286 "x * 1/x should be 1 for x=" << factor); \
287 int64x64_t c = V (1); \
289 NS_TEST_ASSERT_MSG_EQ (c.GetHigh (), 0, \
290 "1 * 1/x should be 0 for x=" << factor); \
291 int64x64_t d = V (1); \
293 NS_TEST_ASSERT_MSG_EQ (d.GetDouble (), c.GetDouble (), \
294 "1 * 1/x should be equal to 1/x for x=" << factor); \
295 int64x64_t e = V (-factor); \
297 NS_TEST_ASSERT_MSG_EQ (e.GetHigh (), -1, \
298 "-x * 1/x should be -1 for x=" << factor); \
317 TEST (10000000000LL);
318 TEST (100000000000LL);
319 TEST (1000000000000LL);
320 TEST (10000000000000LL);
321 TEST (100000000000000LL);
322 TEST (1000000000000000LL);
void CheckFrac(int64_t hi, uint64_t lo)
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoRun(void)
Implementation to actually run this TestCase.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Int64x64128TestSuite g_int64x64TestSuite
Int64x64CompareTestCase()
Int64x64ArithmeticTestCase()
This test suite implements a Unit Test.
virtual void DoRun(void)
Implementation to actually run this TestCase.
#define CHECK_EXPECTED(a, b)
virtual void DoRun(void)
Implementation to actually run 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.