OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "platform/assert.h" | 5 #include "platform/assert.h" |
6 #include "platform/utils.h" | 6 #include "platform/utils.h" |
7 #include "vm/unit_test.h" | 7 #include "vm/unit_test.h" |
8 | 8 |
9 namespace dart { | 9 namespace dart { |
10 | 10 |
11 UNIT_TEST_CASE(Minimum) { | 11 VM_UNIT_TEST_CASE(Minimum) { |
12 EXPECT_EQ(0, Utils::Minimum(0, 1)); | 12 EXPECT_EQ(0, Utils::Minimum(0, 1)); |
13 EXPECT_EQ(0, Utils::Minimum(1, 0)); | 13 EXPECT_EQ(0, Utils::Minimum(1, 0)); |
14 | 14 |
15 EXPECT_EQ(1, Utils::Minimum(1, 2)); | 15 EXPECT_EQ(1, Utils::Minimum(1, 2)); |
16 EXPECT_EQ(1, Utils::Minimum(2, 1)); | 16 EXPECT_EQ(1, Utils::Minimum(2, 1)); |
17 | 17 |
18 EXPECT_EQ(-1, Utils::Minimum(-1, 1)); | 18 EXPECT_EQ(-1, Utils::Minimum(-1, 1)); |
19 EXPECT_EQ(-1, Utils::Minimum(1, -1)); | 19 EXPECT_EQ(-1, Utils::Minimum(1, -1)); |
20 | 20 |
21 EXPECT_EQ(-2, Utils::Minimum(-1, -2)); | 21 EXPECT_EQ(-2, Utils::Minimum(-1, -2)); |
22 EXPECT_EQ(-2, Utils::Minimum(-2, -1)); | 22 EXPECT_EQ(-2, Utils::Minimum(-2, -1)); |
23 } | 23 } |
24 | 24 |
25 | 25 |
26 UNIT_TEST_CASE(Maximum) { | 26 VM_UNIT_TEST_CASE(Maximum) { |
27 EXPECT_EQ(1, Utils::Maximum(0, 1)); | 27 EXPECT_EQ(1, Utils::Maximum(0, 1)); |
28 EXPECT_EQ(1, Utils::Maximum(1, 0)); | 28 EXPECT_EQ(1, Utils::Maximum(1, 0)); |
29 | 29 |
30 EXPECT_EQ(2, Utils::Maximum(1, 2)); | 30 EXPECT_EQ(2, Utils::Maximum(1, 2)); |
31 EXPECT_EQ(2, Utils::Maximum(2, 1)); | 31 EXPECT_EQ(2, Utils::Maximum(2, 1)); |
32 | 32 |
33 EXPECT_EQ(1, Utils::Maximum(-1, 1)); | 33 EXPECT_EQ(1, Utils::Maximum(-1, 1)); |
34 EXPECT_EQ(1, Utils::Maximum(1, -1)); | 34 EXPECT_EQ(1, Utils::Maximum(1, -1)); |
35 | 35 |
36 EXPECT_EQ(-1, Utils::Maximum(-1, -2)); | 36 EXPECT_EQ(-1, Utils::Maximum(-1, -2)); |
37 EXPECT_EQ(-1, Utils::Maximum(-2, -1)); | 37 EXPECT_EQ(-1, Utils::Maximum(-2, -1)); |
38 } | 38 } |
39 | 39 |
40 | 40 |
41 UNIT_TEST_CASE(IsPowerOfTwo) { | 41 VM_UNIT_TEST_CASE(IsPowerOfTwo) { |
42 EXPECT(!Utils::IsPowerOfTwo(0)); | 42 EXPECT(!Utils::IsPowerOfTwo(0)); |
43 EXPECT(Utils::IsPowerOfTwo(1)); | 43 EXPECT(Utils::IsPowerOfTwo(1)); |
44 EXPECT(Utils::IsPowerOfTwo(2)); | 44 EXPECT(Utils::IsPowerOfTwo(2)); |
45 EXPECT(!Utils::IsPowerOfTwo(3)); | 45 EXPECT(!Utils::IsPowerOfTwo(3)); |
46 EXPECT(Utils::IsPowerOfTwo(4)); | 46 EXPECT(Utils::IsPowerOfTwo(4)); |
47 EXPECT(Utils::IsPowerOfTwo(256)); | 47 EXPECT(Utils::IsPowerOfTwo(256)); |
48 | 48 |
49 EXPECT(!Utils::IsPowerOfTwo(-1)); | 49 EXPECT(!Utils::IsPowerOfTwo(-1)); |
50 EXPECT(!Utils::IsPowerOfTwo(-2)); | 50 EXPECT(!Utils::IsPowerOfTwo(-2)); |
51 } | 51 } |
52 | 52 |
53 | 53 |
54 UNIT_TEST_CASE(ShiftForPowerOfTwo) { | 54 VM_UNIT_TEST_CASE(ShiftForPowerOfTwo) { |
55 EXPECT_EQ(1, Utils::ShiftForPowerOfTwo(2)); | 55 EXPECT_EQ(1, Utils::ShiftForPowerOfTwo(2)); |
56 EXPECT_EQ(2, Utils::ShiftForPowerOfTwo(4)); | 56 EXPECT_EQ(2, Utils::ShiftForPowerOfTwo(4)); |
57 EXPECT_EQ(8, Utils::ShiftForPowerOfTwo(256)); | 57 EXPECT_EQ(8, Utils::ShiftForPowerOfTwo(256)); |
58 } | 58 } |
59 | 59 |
60 | 60 |
61 UNIT_TEST_CASE(IsAligned) { | 61 VM_UNIT_TEST_CASE(IsAligned) { |
62 EXPECT(Utils::IsAligned(0, 1)); | 62 EXPECT(Utils::IsAligned(0, 1)); |
63 EXPECT(Utils::IsAligned(1, 1)); | 63 EXPECT(Utils::IsAligned(1, 1)); |
64 | 64 |
65 EXPECT(Utils::IsAligned(0, 2)); | 65 EXPECT(Utils::IsAligned(0, 2)); |
66 EXPECT(!Utils::IsAligned(1, 2)); | 66 EXPECT(!Utils::IsAligned(1, 2)); |
67 EXPECT(Utils::IsAligned(2, 2)); | 67 EXPECT(Utils::IsAligned(2, 2)); |
68 | 68 |
69 EXPECT(Utils::IsAligned(32, 8)); | 69 EXPECT(Utils::IsAligned(32, 8)); |
70 EXPECT(!Utils::IsAligned(33, 8)); | 70 EXPECT(!Utils::IsAligned(33, 8)); |
71 EXPECT(Utils::IsAligned(40, 8)); | 71 EXPECT(Utils::IsAligned(40, 8)); |
72 } | 72 } |
73 | 73 |
74 | 74 |
75 UNIT_TEST_CASE(RoundDown) { | 75 VM_UNIT_TEST_CASE(RoundDown) { |
76 EXPECT_EQ(0, Utils::RoundDown(22, 32)); | 76 EXPECT_EQ(0, Utils::RoundDown(22, 32)); |
77 EXPECT_EQ(32, Utils::RoundDown(33, 32)); | 77 EXPECT_EQ(32, Utils::RoundDown(33, 32)); |
78 EXPECT_EQ(32, Utils::RoundDown(63, 32)); | 78 EXPECT_EQ(32, Utils::RoundDown(63, 32)); |
79 uword* address = reinterpret_cast<uword*>(63); | 79 uword* address = reinterpret_cast<uword*>(63); |
80 uword* rounddown_address = reinterpret_cast<uword*>(32); | 80 uword* rounddown_address = reinterpret_cast<uword*>(32); |
81 EXPECT_EQ(rounddown_address, Utils::RoundDown(address, 32)); | 81 EXPECT_EQ(rounddown_address, Utils::RoundDown(address, 32)); |
82 } | 82 } |
83 | 83 |
84 | 84 |
85 UNIT_TEST_CASE(RoundUp) { | 85 VM_UNIT_TEST_CASE(RoundUp) { |
86 EXPECT_EQ(32, Utils::RoundUp(22, 32)); | 86 EXPECT_EQ(32, Utils::RoundUp(22, 32)); |
87 EXPECT_EQ(64, Utils::RoundUp(33, 32)); | 87 EXPECT_EQ(64, Utils::RoundUp(33, 32)); |
88 EXPECT_EQ(64, Utils::RoundUp(63, 32)); | 88 EXPECT_EQ(64, Utils::RoundUp(63, 32)); |
89 uword* address = reinterpret_cast<uword*>(63); | 89 uword* address = reinterpret_cast<uword*>(63); |
90 uword* roundup_address = reinterpret_cast<uword*>(64); | 90 uword* roundup_address = reinterpret_cast<uword*>(64); |
91 EXPECT_EQ(roundup_address, Utils::RoundUp(address, 32)); | 91 EXPECT_EQ(roundup_address, Utils::RoundUp(address, 32)); |
92 } | 92 } |
93 | 93 |
94 | 94 |
95 UNIT_TEST_CASE(RoundUpToPowerOfTwo) { | 95 VM_UNIT_TEST_CASE(RoundUpToPowerOfTwo) { |
96 EXPECT_EQ(0U, Utils::RoundUpToPowerOfTwo(0)); | 96 EXPECT_EQ(0U, Utils::RoundUpToPowerOfTwo(0)); |
97 EXPECT_EQ(1U, Utils::RoundUpToPowerOfTwo(1)); | 97 EXPECT_EQ(1U, Utils::RoundUpToPowerOfTwo(1)); |
98 EXPECT_EQ(2U, Utils::RoundUpToPowerOfTwo(2)); | 98 EXPECT_EQ(2U, Utils::RoundUpToPowerOfTwo(2)); |
99 EXPECT_EQ(4U, Utils::RoundUpToPowerOfTwo(3)); | 99 EXPECT_EQ(4U, Utils::RoundUpToPowerOfTwo(3)); |
100 EXPECT_EQ(4U, Utils::RoundUpToPowerOfTwo(4)); | 100 EXPECT_EQ(4U, Utils::RoundUpToPowerOfTwo(4)); |
101 EXPECT_EQ(8U, Utils::RoundUpToPowerOfTwo(5)); | 101 EXPECT_EQ(8U, Utils::RoundUpToPowerOfTwo(5)); |
102 EXPECT_EQ(8U, Utils::RoundUpToPowerOfTwo(7)); | 102 EXPECT_EQ(8U, Utils::RoundUpToPowerOfTwo(7)); |
103 EXPECT_EQ(16U, Utils::RoundUpToPowerOfTwo(9)); | 103 EXPECT_EQ(16U, Utils::RoundUpToPowerOfTwo(9)); |
104 EXPECT_EQ(16U, Utils::RoundUpToPowerOfTwo(16)); | 104 EXPECT_EQ(16U, Utils::RoundUpToPowerOfTwo(16)); |
105 EXPECT_EQ(0x10000000U, Utils::RoundUpToPowerOfTwo(0x08765432)); | 105 EXPECT_EQ(0x10000000U, Utils::RoundUpToPowerOfTwo(0x08765432)); |
106 } | 106 } |
107 | 107 |
108 | 108 |
109 UNIT_TEST_CASE(CountOneBits) { | 109 VM_UNIT_TEST_CASE(CountOneBits) { |
110 EXPECT_EQ(0, Utils::CountOneBits(0)); | 110 EXPECT_EQ(0, Utils::CountOneBits(0)); |
111 EXPECT_EQ(1, Utils::CountOneBits(0x00000010)); | 111 EXPECT_EQ(1, Utils::CountOneBits(0x00000010)); |
112 EXPECT_EQ(1, Utils::CountOneBits(0x00010000)); | 112 EXPECT_EQ(1, Utils::CountOneBits(0x00010000)); |
113 EXPECT_EQ(1, Utils::CountOneBits(0x10000000)); | 113 EXPECT_EQ(1, Utils::CountOneBits(0x10000000)); |
114 EXPECT_EQ(4, Utils::CountOneBits(0x10101010)); | 114 EXPECT_EQ(4, Utils::CountOneBits(0x10101010)); |
115 EXPECT_EQ(8, Utils::CountOneBits(0x03030303)); | 115 EXPECT_EQ(8, Utils::CountOneBits(0x03030303)); |
116 EXPECT_EQ(32, Utils::CountOneBits(0xFFFFFFFF)); | 116 EXPECT_EQ(32, Utils::CountOneBits(0xFFFFFFFF)); |
117 } | 117 } |
118 | 118 |
119 | 119 |
120 UNIT_TEST_CASE(CountZeros) { | 120 VM_UNIT_TEST_CASE(CountZeros) { |
121 EXPECT_EQ(0, Utils::CountTrailingZeros(0x1)); | 121 EXPECT_EQ(0, Utils::CountTrailingZeros(0x1)); |
122 EXPECT_EQ(kBitsPerWord - 1, Utils::CountLeadingZeros(0x1)); | 122 EXPECT_EQ(kBitsPerWord - 1, Utils::CountLeadingZeros(0x1)); |
123 EXPECT_EQ(1, Utils::CountTrailingZeros(0x2)); | 123 EXPECT_EQ(1, Utils::CountTrailingZeros(0x2)); |
124 EXPECT_EQ(kBitsPerWord - 2, Utils::CountLeadingZeros(0x2)); | 124 EXPECT_EQ(kBitsPerWord - 2, Utils::CountLeadingZeros(0x2)); |
125 EXPECT_EQ(0, Utils::CountTrailingZeros(0x3)); | 125 EXPECT_EQ(0, Utils::CountTrailingZeros(0x3)); |
126 EXPECT_EQ(kBitsPerWord - 2, Utils::CountLeadingZeros(0x3)); | 126 EXPECT_EQ(kBitsPerWord - 2, Utils::CountLeadingZeros(0x3)); |
127 EXPECT_EQ(2, Utils::CountTrailingZeros(0x4)); | 127 EXPECT_EQ(2, Utils::CountTrailingZeros(0x4)); |
128 EXPECT_EQ(kBitsPerWord - 3, Utils::CountLeadingZeros(0x4)); | 128 EXPECT_EQ(kBitsPerWord - 3, Utils::CountLeadingZeros(0x4)); |
129 EXPECT_EQ(0, Utils::CountTrailingZeros(kUwordMax)); | 129 EXPECT_EQ(0, Utils::CountTrailingZeros(kUwordMax)); |
130 EXPECT_EQ(0, Utils::CountLeadingZeros(kUwordMax)); | 130 EXPECT_EQ(0, Utils::CountLeadingZeros(kUwordMax)); |
131 static const uword kTopBit = static_cast<uword>(1) << (kBitsPerWord - 1); | 131 static const uword kTopBit = static_cast<uword>(1) << (kBitsPerWord - 1); |
132 EXPECT_EQ(kBitsPerWord - 1, Utils::CountTrailingZeros(kTopBit)); | 132 EXPECT_EQ(kBitsPerWord - 1, Utils::CountTrailingZeros(kTopBit)); |
133 EXPECT_EQ(0, Utils::CountLeadingZeros(kTopBit)); | 133 EXPECT_EQ(0, Utils::CountLeadingZeros(kTopBit)); |
134 } | 134 } |
135 | 135 |
136 | 136 |
137 UNIT_TEST_CASE(IsInt) { | 137 VM_UNIT_TEST_CASE(IsInt) { |
138 EXPECT(Utils::IsInt(8, 16)); | 138 EXPECT(Utils::IsInt(8, 16)); |
139 EXPECT(Utils::IsInt(8, 127)); | 139 EXPECT(Utils::IsInt(8, 127)); |
140 EXPECT(Utils::IsInt(8, -128)); | 140 EXPECT(Utils::IsInt(8, -128)); |
141 EXPECT(!Utils::IsInt(8, 255)); | 141 EXPECT(!Utils::IsInt(8, 255)); |
142 EXPECT(Utils::IsInt(16, 16)); | 142 EXPECT(Utils::IsInt(16, 16)); |
143 EXPECT(!Utils::IsInt(16, 65535)); | 143 EXPECT(!Utils::IsInt(16, 65535)); |
144 EXPECT(Utils::IsInt(16, 32767)); | 144 EXPECT(Utils::IsInt(16, 32767)); |
145 EXPECT(Utils::IsInt(16, -32768)); | 145 EXPECT(Utils::IsInt(16, -32768)); |
146 EXPECT(Utils::IsInt(32, 16LL)); | 146 EXPECT(Utils::IsInt(32, 16LL)); |
147 EXPECT(Utils::IsInt(32, 2147483647LL)); | 147 EXPECT(Utils::IsInt(32, 2147483647LL)); |
148 EXPECT(Utils::IsInt(32, -2147483648LL)); | 148 EXPECT(Utils::IsInt(32, -2147483648LL)); |
149 EXPECT(!Utils::IsInt(32, 4294967295LL)); | 149 EXPECT(!Utils::IsInt(32, 4294967295LL)); |
150 } | 150 } |
151 | 151 |
152 | 152 |
153 UNIT_TEST_CASE(IsUint) { | 153 VM_UNIT_TEST_CASE(IsUint) { |
154 EXPECT(Utils::IsUint(8, 16)); | 154 EXPECT(Utils::IsUint(8, 16)); |
155 EXPECT(Utils::IsUint(8, 0)); | 155 EXPECT(Utils::IsUint(8, 0)); |
156 EXPECT(Utils::IsUint(8, 255)); | 156 EXPECT(Utils::IsUint(8, 255)); |
157 EXPECT(!Utils::IsUint(8, 256)); | 157 EXPECT(!Utils::IsUint(8, 256)); |
158 EXPECT(Utils::IsUint(16, 16)); | 158 EXPECT(Utils::IsUint(16, 16)); |
159 EXPECT(Utils::IsUint(16, 0)); | 159 EXPECT(Utils::IsUint(16, 0)); |
160 EXPECT(Utils::IsUint(16, 65535)); | 160 EXPECT(Utils::IsUint(16, 65535)); |
161 EXPECT(!Utils::IsUint(16, 65536)); | 161 EXPECT(!Utils::IsUint(16, 65536)); |
162 EXPECT(Utils::IsUint(32, 16LL)); | 162 EXPECT(Utils::IsUint(32, 16LL)); |
163 EXPECT(Utils::IsUint(32, 0LL)); | 163 EXPECT(Utils::IsUint(32, 0LL)); |
164 EXPECT(Utils::IsUint(32, 4294967295LL)); | 164 EXPECT(Utils::IsUint(32, 4294967295LL)); |
165 EXPECT(!Utils::IsUint(32, 4294967296LL)); | 165 EXPECT(!Utils::IsUint(32, 4294967296LL)); |
166 } | 166 } |
167 | 167 |
168 | 168 |
169 UNIT_TEST_CASE(IsAbsoluteUint) { | 169 VM_UNIT_TEST_CASE(IsAbsoluteUint) { |
170 EXPECT(Utils::IsAbsoluteUint(8, 16)); | 170 EXPECT(Utils::IsAbsoluteUint(8, 16)); |
171 EXPECT(Utils::IsAbsoluteUint(8, 0)); | 171 EXPECT(Utils::IsAbsoluteUint(8, 0)); |
172 EXPECT(Utils::IsAbsoluteUint(8, -128)); | 172 EXPECT(Utils::IsAbsoluteUint(8, -128)); |
173 EXPECT(Utils::IsAbsoluteUint(8, 255)); | 173 EXPECT(Utils::IsAbsoluteUint(8, 255)); |
174 EXPECT(!Utils::IsAbsoluteUint(8, 256)); | 174 EXPECT(!Utils::IsAbsoluteUint(8, 256)); |
175 EXPECT(Utils::IsAbsoluteUint(16, 16)); | 175 EXPECT(Utils::IsAbsoluteUint(16, 16)); |
176 EXPECT(Utils::IsAbsoluteUint(16, 0)); | 176 EXPECT(Utils::IsAbsoluteUint(16, 0)); |
177 EXPECT(Utils::IsAbsoluteUint(16, 65535)); | 177 EXPECT(Utils::IsAbsoluteUint(16, 65535)); |
178 EXPECT(Utils::IsAbsoluteUint(16, -32768)); | 178 EXPECT(Utils::IsAbsoluteUint(16, -32768)); |
179 EXPECT(!Utils::IsAbsoluteUint(16, 65536)); | 179 EXPECT(!Utils::IsAbsoluteUint(16, 65536)); |
180 EXPECT(Utils::IsAbsoluteUint(32, 16LL)); | 180 EXPECT(Utils::IsAbsoluteUint(32, 16LL)); |
181 EXPECT(Utils::IsAbsoluteUint(32, 0LL)); | 181 EXPECT(Utils::IsAbsoluteUint(32, 0LL)); |
182 EXPECT(Utils::IsAbsoluteUint(32, -2147483648LL)); | 182 EXPECT(Utils::IsAbsoluteUint(32, -2147483648LL)); |
183 EXPECT(Utils::IsAbsoluteUint(32, 4294967295LL)); | 183 EXPECT(Utils::IsAbsoluteUint(32, 4294967295LL)); |
184 EXPECT(!Utils::IsAbsoluteUint(32, 4294967296LL)); | 184 EXPECT(!Utils::IsAbsoluteUint(32, 4294967296LL)); |
185 } | 185 } |
186 | 186 |
187 | 187 |
188 UNIT_TEST_CASE(LowBits) { | 188 VM_UNIT_TEST_CASE(LowBits) { |
189 EXPECT_EQ(0xff00, Utils::Low16Bits(0xffff00)); | 189 EXPECT_EQ(0xff00, Utils::Low16Bits(0xffff00)); |
190 EXPECT_EQ(0xff, Utils::High16Bits(0xffff00)); | 190 EXPECT_EQ(0xff, Utils::High16Bits(0xffff00)); |
191 EXPECT_EQ(0xff00, Utils::Low32Bits(0xff0000ff00LL)); | 191 EXPECT_EQ(0xff00, Utils::Low32Bits(0xff0000ff00LL)); |
192 EXPECT_EQ(0xff, Utils::High32Bits(0xff0000ff00LL)); | 192 EXPECT_EQ(0xff, Utils::High32Bits(0xff0000ff00LL)); |
193 EXPECT_EQ(0x00ff0000ff00LL, Utils::LowHighTo64Bits(0xff00, 0x00ff)); | 193 EXPECT_EQ(0x00ff0000ff00LL, Utils::LowHighTo64Bits(0xff00, 0x00ff)); |
194 } | 194 } |
195 | 195 |
196 | 196 |
197 UNIT_TEST_CASE(Endianity) { | 197 VM_UNIT_TEST_CASE(Endianity) { |
198 uint16_t value16be = Utils::HostToBigEndian16(0xf1); | 198 uint16_t value16be = Utils::HostToBigEndian16(0xf1); |
199 EXPECT_EQ(0x0, reinterpret_cast<uint8_t*>(&value16be)[0]); | 199 EXPECT_EQ(0x0, reinterpret_cast<uint8_t*>(&value16be)[0]); |
200 EXPECT_EQ(0xf1, reinterpret_cast<uint8_t*>(&value16be)[1]); | 200 EXPECT_EQ(0xf1, reinterpret_cast<uint8_t*>(&value16be)[1]); |
201 | 201 |
202 uint16_t value16le = Utils::HostToLittleEndian16(0xf1); | 202 uint16_t value16le = Utils::HostToLittleEndian16(0xf1); |
203 EXPECT_EQ(0xf1, reinterpret_cast<uint8_t*>(&value16le)[0]); | 203 EXPECT_EQ(0xf1, reinterpret_cast<uint8_t*>(&value16le)[0]); |
204 EXPECT_EQ(0x0, reinterpret_cast<uint8_t*>(&value16le)[1]); | 204 EXPECT_EQ(0x0, reinterpret_cast<uint8_t*>(&value16le)[1]); |
205 | 205 |
206 uint32_t value32be = Utils::HostToBigEndian32(0xf1f2); | 206 uint32_t value32be = Utils::HostToBigEndian32(0xf1f2); |
207 EXPECT_EQ(0x0, reinterpret_cast<uint8_t*>(&value32be)[0]); | 207 EXPECT_EQ(0x0, reinterpret_cast<uint8_t*>(&value32be)[0]); |
(...skipping 22 matching lines...) Expand all Loading... |
230 EXPECT_EQ(0xf3, reinterpret_cast<uint8_t*>(&value64le)[1]); | 230 EXPECT_EQ(0xf3, reinterpret_cast<uint8_t*>(&value64le)[1]); |
231 EXPECT_EQ(0xf2, reinterpret_cast<uint8_t*>(&value64le)[2]); | 231 EXPECT_EQ(0xf2, reinterpret_cast<uint8_t*>(&value64le)[2]); |
232 EXPECT_EQ(0xf1, reinterpret_cast<uint8_t*>(&value64le)[3]); | 232 EXPECT_EQ(0xf1, reinterpret_cast<uint8_t*>(&value64le)[3]); |
233 EXPECT_EQ(0x0, reinterpret_cast<uint8_t*>(&value64le)[4]); | 233 EXPECT_EQ(0x0, reinterpret_cast<uint8_t*>(&value64le)[4]); |
234 EXPECT_EQ(0x0, reinterpret_cast<uint8_t*>(&value64le)[5]); | 234 EXPECT_EQ(0x0, reinterpret_cast<uint8_t*>(&value64le)[5]); |
235 EXPECT_EQ(0x0, reinterpret_cast<uint8_t*>(&value64le)[6]); | 235 EXPECT_EQ(0x0, reinterpret_cast<uint8_t*>(&value64le)[6]); |
236 EXPECT_EQ(0x0, reinterpret_cast<uint8_t*>(&value64le)[7]); | 236 EXPECT_EQ(0x0, reinterpret_cast<uint8_t*>(&value64le)[7]); |
237 } | 237 } |
238 | 238 |
239 | 239 |
240 UNIT_TEST_CASE(DoublesBitEqual) { | 240 VM_UNIT_TEST_CASE(DoublesBitEqual) { |
241 EXPECT(Utils::DoublesBitEqual(1.0, 1.0)); | 241 EXPECT(Utils::DoublesBitEqual(1.0, 1.0)); |
242 EXPECT(!Utils::DoublesBitEqual(1.0, -1.0)); | 242 EXPECT(!Utils::DoublesBitEqual(1.0, -1.0)); |
243 EXPECT(Utils::DoublesBitEqual(0.0, 0.0)); | 243 EXPECT(Utils::DoublesBitEqual(0.0, 0.0)); |
244 EXPECT(!Utils::DoublesBitEqual(0.0, -0.0)); | 244 EXPECT(!Utils::DoublesBitEqual(0.0, -0.0)); |
245 EXPECT(Utils::DoublesBitEqual(NAN, NAN)); | 245 EXPECT(Utils::DoublesBitEqual(NAN, NAN)); |
246 } | 246 } |
247 | 247 |
248 } // namespace dart | 248 } // namespace dart |
OLD | NEW |