diff options
Diffstat (limited to 'src/processor/range_map_unittest.cc')
-rw-r--r-- | src/processor/range_map_unittest.cc | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/src/processor/range_map_unittest.cc b/src/processor/range_map_unittest.cc index 31b89e5d..2745e809 100644 --- a/src/processor/range_map_unittest.cc +++ b/src/processor/range_map_unittest.cc @@ -1,5 +1,4 @@ -// Copyright (c) 2010 Google Inc. -// All rights reserved. +// Copyright 2010 Google LLC // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -11,7 +10,7 @@ // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. -// * Neither the name of Google Inc. nor the names of its +// * Neither the name of Google LLC nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // @@ -43,11 +42,10 @@ namespace { - +using google_breakpad::AddIgnoringOverflow; using google_breakpad::linked_ptr; -using google_breakpad::scoped_ptr; using google_breakpad::RangeMap; - +using google_breakpad::scoped_ptr; // A CountedObject holds an int. A global (not thread safe!) count of // allocated CountedObjects is maintained to help test memory management. @@ -92,7 +90,7 @@ struct RangeTest { // sequence on the same RangeMap. struct RangeTestSet { // An array of RangeTests - const RangeTest *range_tests; + const RangeTest* range_tests; // The number of tests in the set unsigned int range_test_count; @@ -102,7 +100,7 @@ struct RangeTestSet { // StoreTest uses the data in a RangeTest and calls StoreRange on the // test RangeMap. It returns true if the expected result occurred, and // false if something else happened. -static bool StoreTest(TestMap *range_map, const RangeTest *range_test) { +static bool StoreTest(TestMap* range_map, const RangeTest* range_test) { linked_ptr<CountedObject> object(new CountedObject(range_test->id)); bool stored = range_map->StoreRange(range_test->address, range_test->size, @@ -126,7 +124,7 @@ static bool StoreTest(TestMap *range_map, const RangeTest *range_test) { // map entry at the specified range,) it returns true, otherwise, it returns // false. RetrieveTest will check the values around the base address and // the high address of a range to guard against off-by-one errors. -static bool RetrieveTest(TestMap *range_map, const RangeTest *range_test) { +static bool RetrieveTest(TestMap* range_map, const RangeTest* range_test) { for (unsigned int side = 0; side <= 1; ++side) { // When side == 0, check the low side (base address) of each range. // When side == 1, check the high side (base + size) of each range. @@ -148,10 +146,10 @@ static bool RetrieveTest(TestMap *range_map, const RangeTest *range_test) { } for (AddressType offset = low_offset; offset <= high_offset; ++offset) { - AddressType address = - offset + - (!side ? range_test->address : - range_test->address + range_test->size - 1); + AddressType address = AddIgnoringOverflow( + offset, (!side ? range_test->address + : AddIgnoringOverflow(range_test->address, + range_test->size - 1))); bool expected_result = false; // This is correct for tests not stored. if (range_test->expect_storable) { @@ -270,9 +268,9 @@ static bool RetrieveTest(TestMap *range_map, const RangeTest *range_test) { // and verifying that each call returns a different object than the previous // call, and that ranges are returned with increasing base addresses. Returns // false if the test fails. -static bool RetrieveIndexTest(TestMap *range_map, int set) { +static bool RetrieveIndexTest(TestMap* range_map, int set) { linked_ptr<CountedObject> object; - CountedObject *last_object = NULL; + CountedObject* last_object = NULL; AddressType last_base = 0; int object_count = range_map->GetCount(); @@ -469,7 +467,7 @@ static bool RunTests() { for (unsigned int range_test_set_index = 0; range_test_set_index < range_test_set_count; ++range_test_set_index) { - const RangeTest *range_tests = + const RangeTest* range_tests = range_test_sets[range_test_set_index].range_tests; unsigned int range_test_count = range_test_sets[range_test_set_index].range_test_count; @@ -480,7 +478,7 @@ static bool RunTests() { for (unsigned int range_test_index = 0; range_test_index < range_test_count; ++range_test_index) { - const RangeTest *range_test = &range_tests[range_test_index]; + const RangeTest* range_test = &range_tests[range_test_index]; if (!StoreTest(range_map.get(), range_test)) return false; @@ -512,7 +510,7 @@ static bool RunTests() { for (unsigned int range_test_index = 0; range_test_index < range_test_count; ++range_test_index) { - const RangeTest *range_test = &range_tests[range_test_index]; + const RangeTest* range_test = &range_tests[range_test_index]; if (!RetrieveTest(range_map.get(), range_test)) return false; } @@ -552,7 +550,7 @@ static bool RunTests() { } // namespace -int main(int argc, char **argv) { +int main(int argc, char** argv) { BPLOG_INIT(&argc, &argv); return RunTests() ? 0 : 1; |