OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2011 INRIA | 3 * Copyright (c) 2011 INRIA |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 Int64x64HiLoTestCase::DoRun (void) | 164 Int64x64HiLoTestCase::DoRun (void) |
165 { | 165 { |
166 std::cout << std::endl; | 166 std::cout << std::endl; |
167 std::cout << GetParent ()->GetName () << " Check: " << GetName () | 167 std::cout << GetParent ()->GetName () << " Check: " << GetName () |
168 << std::endl; | 168 << std::endl; |
169 | 169 |
170 uint64_t low = 1; | 170 uint64_t low = 1; |
171 if (int64x64_t::implementation == int64x64_t::ld_impl) | 171 if (int64x64_t::implementation == int64x64_t::ld_impl) |
172 { | 172 { |
173 // Darwin 12.5.0 (Mac 10.8.5) g++ 4.2.1 | 173 // Darwin 12.5.0 (Mac 10.8.5) g++ 4.2.1 |
174 low = HP_MAX_64 * std::numeric_limits<long double>::epsilon (); | 174 low = static_cast<uint64_t> (HP_MAX_64 * std::numeric_limits<long double>:
:epsilon ()); |
175 } | 175 } |
176 | 176 |
177 Check ( 0, 0); | 177 Check ( 0, 0); |
178 Check ( 0, low); | 178 Check ( 0, low); |
179 Check ( 0, 0xffffffffffffffffULL - low); | 179 Check ( 0, 0xffffffffffffffffULL - low); |
180 ·· | 180 ·· |
181 Check ( 1, 0); | 181 Check ( 1, 0); |
182 Check ( 1, low); | 182 Check ( 1, low); |
183 Check ( 1, 0xffffffffffffffffULL - low); | 183 Check ( 1, 0xffffffffffffffffULL - low); |
184 ·· | 184 ·· |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 Check ("1.0", 1, 0); | 252 Check ("1.0", 1, 0); |
253 Check ("+1.0", 1, 0); | 253 Check ("+1.0", 1, 0); |
254 Check ("001.0", 1, 0); | 254 Check ("001.0", 1, 0); |
255 Check ("+001.0", 1, 0); | 255 Check ("+001.0", 1, 0); |
256 Check ("020.0", 20, 0); | 256 Check ("020.0", 20, 0); |
257 Check ("+020.0", 20, 0); | 257 Check ("+020.0", 20, 0); |
258 Check ("1.0000000", 1, 0); | 258 Check ("1.0000000", 1, 0); |
259 Check ("-1.0", -1, 0, tolerance); | 259 Check ("-1.0", -1, 0, tolerance); |
260 Check ("-1.0000", -1, 0, tolerance); | 260 Check ("-1.0000", -1, 0, tolerance); |
261 Check (" 1.000000000000000000054", 1, 1, tolerance); | 261 Check (" 1.000000000000000000054", 1, 1, tolerance); |
262 Check ("-1.000000000000000000054", -2, -1, tolerance); | 262 Check ("-1.000000000000000000054", (int64_t)-2, (uint64_t)-1, tolerance); |
263 } | 263 } |
264 | 264 |
265 | 265 |
266 class Int64x64InputOutputTestCase : public TestCase | 266 class Int64x64InputOutputTestCase : public TestCase |
267 { | 267 { |
268 public: | 268 public: |
269 Int64x64InputOutputTestCase (); | 269 Int64x64InputOutputTestCase (); |
270 virtual void DoRun (void); | 270 virtual void DoRun (void); |
271 void Check (const std::string & str, | 271 void Check (const std::string & str, |
272 const int64_t tolerance = 0); | 272 const int64_t tolerance = 0); |
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 | 1071 |
1072 } | 1072 } |
1073 | 1073 |
1074 void | 1074 void |
1075 Int64x64DoubleTestCase::Check (const int64_t intPart) | 1075 Int64x64DoubleTestCase::Check (const int64_t intPart) |
1076 { | 1076 { |
1077 std::cout << std::endl; | 1077 std::cout << std::endl; |
1078 std::cout << GetParent ()->GetName () << " Double: " | 1078 std::cout << GetParent ()->GetName () << " Double: " |
1079 << "integer: " << intPart | 1079 << "integer: " << intPart |
1080 << std::endl; | 1080 << std::endl; |
1081 m_last = intPart; | 1081 m_last = static_cast<long double> (intPart); |
1082 m_deltaCount = 0; | 1082 m_deltaCount = 0; |
1083 | 1083 |
1084 // Nudging the integer part eliminates deltas around 0 | 1084 // Nudging the integer part eliminates deltas around 0 |
1085 long double v = intPart; | 1085 long double v = static_cast<long double> (intPart); |
1086 ·· | 1086 ·· |
1087 Check (v +0.0000000000000000000542L, intPart, 0x1ULL); | 1087 Check (v +0.0000000000000000000542L, intPart, 0x1ULL); |
1088 Check (v +0.0000000000000000001084L, intPart, 0x2ULL); | 1088 Check (v +0.0000000000000000001084L, intPart, 0x2ULL); |
1089 Check (v +0.0000000000000000001626L, intPart, 0x3ULL); | 1089 Check (v +0.0000000000000000001626L, intPart, 0x3ULL); |
1090 Check (v +0.0000000000000000002168L, intPart, 0x4ULL); | 1090 Check (v +0.0000000000000000002168L, intPart, 0x4ULL); |
1091 Check (v +0.0000000000000000002710L, intPart, 0x5ULL); | 1091 Check (v +0.0000000000000000002710L, intPart, 0x5ULL); |
1092 Check (v +0.0000000000000000003253L, intPart, 0x6ULL); | 1092 Check (v +0.0000000000000000003253L, intPart, 0x6ULL); |
1093 Check (v +0.0000000000000000003795L, intPart, 0x7ULL); | 1093 Check (v +0.0000000000000000003795L, intPart, 0x7ULL); |
1094 Check (v +0.0000000000000000004337L, intPart, 0x8ULL); | 1094 Check (v +0.0000000000000000004337L, intPart, 0x8ULL); |
1095 Check (v +0.0000000000000000004879L, intPart, 0x9ULL); | 1095 Check (v +0.0000000000000000004879L, intPart, 0x9ULL); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1243 AddTestCase (new Int64x64DoubleTestCase (), TestCase::QUICK); | 1243 AddTestCase (new Int64x64DoubleTestCase (), TestCase::QUICK); |
1244 } | 1244 } |
1245 } g_int64x64TestSuite; | 1245 } g_int64x64TestSuite; |
1246 | 1246 |
1247 } // namespace test | 1247 } // namespace test |
1248 | 1248 |
1249 } // namespace int64x64 | 1249 } // namespace int64x64 |
1250 | 1250 |
1251 } // namespace ns3 | 1251 } // namespace ns3 |
1252 | 1252 |
OLD | NEW |