OLD | NEW |
---|---|
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 index, | 239 index, |
240 testcase.base, | 240 testcase.base, |
241 testcase.size)); | 241 testcase.size)); |
242 | 242 |
243 CheckedRange<uint32_t> child_range(testcase.base, testcase.size); | 243 CheckedRange<uint32_t> child_range(testcase.base, testcase.size); |
244 ASSERT_TRUE(child_range.IsValid()); | 244 ASSERT_TRUE(child_range.IsValid()); |
245 EXPECT_EQ(testcase.valid, parent_range.ContainsRange(child_range)); | 245 EXPECT_EQ(testcase.valid, parent_range.ContainsRange(child_range)); |
246 } | 246 } |
247 } | 247 } |
248 | 248 |
249 TEST(CheckedRange, OverlapsRange) { | |
250 const struct TestData { | |
251 uint32_t base; | |
252 uint32_t size; | |
253 bool valid; | |
Mark Mentovai
2015/10/01 17:38:58
This is more “overlaps” than valid. The member nam
scottmg
2015/10/01 18:10:02
Done.
| |
254 } kTestData[] = { | |
255 {0, 0, false}, | |
256 {0, 1, false}, | |
257 {0x2000, 0x1000, true}, | |
258 {0, 0x2000, false}, | |
259 {0x3000, 0x1000, false}, | |
260 {0x1800, 0x1000, true}, | |
261 {0x1800, 0x2000, true}, | |
262 {0x2800, 0x1000, true}, | |
263 {0x2000, 0x800, true}, | |
264 {0x2800, 0x800, true}, | |
265 {0x2400, 0x800, true}, | |
266 {0x2800, 0, true}, | |
Mark Mentovai
2015/10/01 17:38:58
This one might be a little weird. Should a 0-sized
scottmg
2015/10/01 18:10:02
Yeah, the other weird case is <0x2000, 0> = false
Mark Mentovai
2015/10/01 18:29:12
scottmg wrote:
| |
267 {0x2000, 0xffffdfff, true}, | |
268 {0x2800, 0xffffd7ff, true}, | |
269 {0x3000, 0xffffcfff, false}, | |
270 {0xfffffffe, 1, false}, | |
271 {0xffffffff, 0, false}, | |
272 {0x1fff, 0, false}, | |
273 {0x2000, 0, false}, | |
274 {0x2001, 0, true}, | |
275 {0x2fff, 0, true}, | |
276 {0x3000, 0, false}, | |
277 {0x3001, 0, false}, | |
278 {0x1fff, 1, false}, | |
279 {0x2000, 1, true}, | |
280 {0x2001, 1, true}, | |
281 {0x2fff, 1, true}, | |
282 {0x3000, 1, false}, | |
283 {0x3001, 1, false}, | |
284 }; | |
285 | |
286 CheckedRange<uint32_t> first_range(0x2000, 0x1000); | |
287 ASSERT_TRUE(first_range.IsValid()); | |
288 | |
289 for (size_t index = 0; index < arraysize(kTestData); ++index) { | |
290 const TestData& testcase = kTestData[index]; | |
291 SCOPED_TRACE(base::StringPrintf("index %" PRIuS ", base 0x%x, size 0x%x", | |
292 index, | |
293 testcase.base, | |
294 testcase.size)); | |
295 | |
296 CheckedRange<uint32_t> second_range(testcase.base, testcase.size); | |
297 ASSERT_TRUE(second_range.IsValid()); | |
298 EXPECT_EQ(testcase.valid, first_range.OverlapsRange(second_range)); | |
299 } | |
300 } | |
301 | |
249 } // namespace | 302 } // namespace |
250 } // namespace test | 303 } // namespace test |
251 } // namespace crashpad | 304 } // namespace crashpad |
OLD | NEW |