| OLD | NEW |
| 1 // Copyright (c) 2010, Google Inc. | 1 // Copyright (c) 2010, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 1, | 230 1, |
| 231 // Offsets | 231 // Offsets |
| 232 12, | 232 12, |
| 233 // Keys: high address | 233 // Keys: high address |
| 234 10, | 234 10, |
| 235 // Values: (low address, entry) pairs | 235 // Values: (low address, entry) pairs |
| 236 1, 6 | 236 1, 6 |
| 237 }; | 237 }; |
| 238 uint32_t correct_size = sizeof(correct_data); | 238 uint32_t correct_size = sizeof(correct_data); |
| 239 | 239 |
| 240 range_map_.StoreRange(1, 10, 6); | 240 range_map_.StoreRange(1, 0 /* delta */, 10, 6); |
| 241 | 241 |
| 242 serialized_data_ = serializer_.Serialize(range_map_, &serialized_size_); | 242 serialized_data_ = serializer_.Serialize(range_map_, &serialized_size_); |
| 243 | 243 |
| 244 EXPECT_EQ(correct_size, serialized_size_); | 244 EXPECT_EQ(correct_size, serialized_size_); |
| 245 EXPECT_EQ(memcmp(correct_data, serialized_data_, correct_size), 0); | 245 EXPECT_EQ(memcmp(correct_data, serialized_data_, correct_size), 0); |
| 246 } | 246 } |
| 247 | 247 |
| 248 TEST_F(TestRangeMapSerializer, MapWithThreeRangesTestCase) { | 248 TEST_F(TestRangeMapSerializer, MapWithThreeRangesTestCase) { |
| 249 const int32_t correct_data[] = { | 249 const int32_t correct_data[] = { |
| 250 // # of nodes | 250 // # of nodes |
| 251 3, | 251 3, |
| 252 // Offsets | 252 // Offsets |
| 253 28, 36, 44, | 253 28, 36, 44, |
| 254 // Keys: high address | 254 // Keys: high address |
| 255 5, 9, 20, | 255 5, 9, 20, |
| 256 // Values: (low address, entry) pairs | 256 // Values: (low address, entry) pairs |
| 257 2, 1, 6, 2, 10, 3 | 257 2, 1, 6, 2, 10, 3 |
| 258 }; | 258 }; |
| 259 uint32_t correct_size = sizeof(correct_data); | 259 uint32_t correct_size = sizeof(correct_data); |
| 260 | 260 |
| 261 ASSERT_TRUE(range_map_.StoreRange(2, 4, 1)); | 261 ASSERT_TRUE(range_map_.StoreRange(2, 0 /* delta */, 4, 1)); |
| 262 ASSERT_TRUE(range_map_.StoreRange(6, 4, 2)); | 262 ASSERT_TRUE(range_map_.StoreRange(6, 0 /* delta */, 4, 2)); |
| 263 ASSERT_TRUE(range_map_.StoreRange(10, 11, 3)); | 263 ASSERT_TRUE(range_map_.StoreRange(10, 0 /* delta */, 11, 3)); |
| 264 | 264 |
| 265 serialized_data_ = serializer_.Serialize(range_map_, &serialized_size_); | 265 serialized_data_ = serializer_.Serialize(range_map_, &serialized_size_); |
| 266 | 266 |
| 267 EXPECT_EQ(correct_size, serialized_size_); | 267 EXPECT_EQ(correct_size, serialized_size_); |
| 268 EXPECT_EQ(memcmp(correct_data, serialized_data_, correct_size), 0); | 268 EXPECT_EQ(memcmp(correct_data, serialized_data_, correct_size), 0); |
| 269 } | 269 } |
| 270 | 270 |
| 271 | 271 |
| 272 class TestContainedRangeMapSerializer : public ::testing::Test { | 272 class TestContainedRangeMapSerializer : public ::testing::Test { |
| 273 protected: | 273 protected: |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 EXPECT_EQ(correct_size, serialized_size_); | 377 EXPECT_EQ(correct_size, serialized_size_); |
| 378 EXPECT_EQ(memcmp(correct_data, serialized_data_, correct_size), 0); | 378 EXPECT_EQ(memcmp(correct_data, serialized_data_, correct_size), 0); |
| 379 } | 379 } |
| 380 | 380 |
| 381 | 381 |
| 382 int main(int argc, char *argv[]) { | 382 int main(int argc, char *argv[]) { |
| 383 ::testing::InitGoogleTest(&argc, argv); | 383 ::testing::InitGoogleTest(&argc, argv); |
| 384 | 384 |
| 385 return RUN_ALL_TESTS(); | 385 return RUN_ALL_TESTS(); |
| 386 } | 386 } |
| OLD | NEW |