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 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 UNIT_TEST_CASE(IsInt) { | 124 UNIT_TEST_CASE(IsInt) { |
125 EXPECT(Utils::IsInt(8, 16)); | 125 EXPECT(Utils::IsInt(8, 16)); |
126 EXPECT(Utils::IsInt(8, 127)); | 126 EXPECT(Utils::IsInt(8, 127)); |
127 EXPECT(Utils::IsInt(8, -128)); | 127 EXPECT(Utils::IsInt(8, -128)); |
128 EXPECT(!Utils::IsInt(8, 255)); | 128 EXPECT(!Utils::IsInt(8, 255)); |
129 EXPECT(Utils::IsInt(16, 16)); | 129 EXPECT(Utils::IsInt(16, 16)); |
130 EXPECT(!Utils::IsInt(16, 65535)); | 130 EXPECT(!Utils::IsInt(16, 65535)); |
131 EXPECT(Utils::IsInt(16, 32767)); | 131 EXPECT(Utils::IsInt(16, 32767)); |
132 EXPECT(Utils::IsInt(16, -32768)); | 132 EXPECT(Utils::IsInt(16, -32768)); |
| 133 EXPECT(Utils::IsInt(32, 16LL)); |
| 134 EXPECT(Utils::IsInt(32, 2147483647LL)); |
| 135 EXPECT(Utils::IsInt(32, -2147483648LL)); |
| 136 EXPECT(!Utils::IsInt(32, 4294967295LL)); |
133 } | 137 } |
134 | 138 |
135 | 139 |
136 UNIT_TEST_CASE(IsUint) { | 140 UNIT_TEST_CASE(IsUint) { |
137 EXPECT(Utils::IsUint(8, 16)); | 141 EXPECT(Utils::IsUint(8, 16)); |
138 EXPECT(Utils::IsUint(8, 0)); | 142 EXPECT(Utils::IsUint(8, 0)); |
139 EXPECT(Utils::IsUint(8, 255)); | 143 EXPECT(Utils::IsUint(8, 255)); |
140 EXPECT(!Utils::IsUint(8, 256)); | 144 EXPECT(!Utils::IsUint(8, 256)); |
141 EXPECT(Utils::IsUint(16, 16)); | 145 EXPECT(Utils::IsUint(16, 16)); |
142 EXPECT(Utils::IsUint(16, 0)); | 146 EXPECT(Utils::IsUint(16, 0)); |
143 EXPECT(Utils::IsUint(16, 65535)); | 147 EXPECT(Utils::IsUint(16, 65535)); |
144 EXPECT(!Utils::IsUint(16, 65536)); | 148 EXPECT(!Utils::IsUint(16, 65536)); |
| 149 EXPECT(Utils::IsUint(32, 16LL)); |
| 150 EXPECT(Utils::IsUint(32, 0LL)); |
| 151 EXPECT(Utils::IsUint(32, 4294967295LL)); |
| 152 EXPECT(!Utils::IsUint(32, 4294967296LL)); |
145 } | 153 } |
146 | 154 |
147 | 155 |
148 UNIT_TEST_CASE(IsAbsoluteUint) { | 156 UNIT_TEST_CASE(IsAbsoluteUint) { |
149 EXPECT(Utils::IsAbsoluteUint(8, 16)); | 157 EXPECT(Utils::IsAbsoluteUint(8, 16)); |
150 EXPECT(Utils::IsAbsoluteUint(8, 0)); | 158 EXPECT(Utils::IsAbsoluteUint(8, 0)); |
151 EXPECT(Utils::IsAbsoluteUint(8, -128)); | 159 EXPECT(Utils::IsAbsoluteUint(8, -128)); |
152 EXPECT(Utils::IsAbsoluteUint(8, 255)); | 160 EXPECT(Utils::IsAbsoluteUint(8, 255)); |
153 EXPECT(!Utils::IsAbsoluteUint(8, 256)); | 161 EXPECT(!Utils::IsAbsoluteUint(8, 256)); |
154 EXPECT(Utils::IsAbsoluteUint(16, 16)); | 162 EXPECT(Utils::IsAbsoluteUint(16, 16)); |
155 EXPECT(Utils::IsAbsoluteUint(16, 0)); | 163 EXPECT(Utils::IsAbsoluteUint(16, 0)); |
156 EXPECT(Utils::IsAbsoluteUint(16, 65535)); | 164 EXPECT(Utils::IsAbsoluteUint(16, 65535)); |
157 EXPECT(Utils::IsAbsoluteUint(16, -32768)); | 165 EXPECT(Utils::IsAbsoluteUint(16, -32768)); |
158 EXPECT(!Utils::IsAbsoluteUint(16, 65536)); | 166 EXPECT(!Utils::IsAbsoluteUint(16, 65536)); |
| 167 EXPECT(Utils::IsAbsoluteUint(32, 16LL)); |
| 168 EXPECT(Utils::IsAbsoluteUint(32, 0LL)); |
| 169 EXPECT(Utils::IsAbsoluteUint(32, -2147483648LL)); |
| 170 EXPECT(Utils::IsAbsoluteUint(32, 4294967295LL)); |
| 171 EXPECT(!Utils::IsAbsoluteUint(32, 4294967296LL)); |
159 } | 172 } |
160 | 173 |
161 | 174 |
162 UNIT_TEST_CASE(LowBits) { | 175 UNIT_TEST_CASE(LowBits) { |
163 EXPECT_EQ(0xff00, Utils::Low16Bits(0xffff00)); | 176 EXPECT_EQ(0xff00, Utils::Low16Bits(0xffff00)); |
164 EXPECT_EQ(0xff, Utils::High16Bits(0xffff00)); | 177 EXPECT_EQ(0xff, Utils::High16Bits(0xffff00)); |
165 EXPECT_EQ(0xff00, Utils::Low32Bits(0xff0000ff00LL)); | 178 EXPECT_EQ(0xff00, Utils::Low32Bits(0xff0000ff00LL)); |
166 EXPECT_EQ(0xff, Utils::High32Bits(0xff0000ff00LL)); | 179 EXPECT_EQ(0xff, Utils::High32Bits(0xff0000ff00LL)); |
167 EXPECT_EQ(0x00ff0000ff00LL, Utils::LowHighTo64Bits(0xff00, 0x00ff)); | 180 EXPECT_EQ(0x00ff0000ff00LL, Utils::LowHighTo64Bits(0xff00, 0x00ff)); |
168 } | 181 } |
169 | 182 |
170 } // namespace dart | 183 } // namespace dart |
OLD | NEW |