Index: src/processor/static_map_unittest.cc |
=================================================================== |
--- a/src/processor/static_map_unittest.cc |
+++ b/src/processor/static_map_unittest.cc |
@@ -44,31 +44,31 @@ typedef google_breakpad::StaticMap< KeyT |
typedef std::map< KeyType, ValueType > StdMap; |
template<typename Key, typename Value> |
class SimpleMapSerializer { |
public: |
static char* Serialize(const std::map<Key, Value> &stdmap, |
unsigned int* size = NULL) { |
unsigned int size_per_node = |
- sizeof(u_int32_t) + sizeof(Key) + sizeof(Value); |
+ sizeof(uint32_t) + sizeof(Key) + sizeof(Value); |
unsigned int memsize = sizeof(int32_t) + size_per_node * stdmap.size(); |
if (size) *size = memsize; |
// Allocate memory for serialized data: |
char* mem = reinterpret_cast<char*>(operator new(memsize)); |
char* address = mem; |
// Writer the number of nodes: |
- new (address) u_int32_t(static_cast<u_int32_t>(stdmap.size())); |
- address += sizeof(u_int32_t); |
+ new (address) uint32_t(static_cast<uint32_t>(stdmap.size())); |
+ address += sizeof(uint32_t); |
// Nodes' offset: |
- u_int32_t* offsets = reinterpret_cast<u_int32_t*>(address); |
- address += sizeof(u_int32_t) * stdmap.size(); |
+ uint32_t* offsets = reinterpret_cast<uint32_t*>(address); |
+ address += sizeof(uint32_t) * stdmap.size(); |
// Keys: |
Key* keys = reinterpret_cast<Key*>(address); |
address += sizeof(Key) * stdmap.size(); |
// Traversing map: |
typename std::map<Key, Value>::const_iterator iter = stdmap.begin(); |
for (int index = 0; iter != stdmap.end(); ++iter, ++index) { |
@@ -90,49 +90,49 @@ class TestInvalidMap : public ::testing: |
// 40 Bytes memory can hold a StaticMap with up to 3 nodes. |
static const int kMemorySize = 40; |
char data[kMemorySize]; |
TestMap test_map; |
}; |
TEST_F(TestInvalidMap, TestNegativeNumberNodes) { |
- memset(data, 0xff, sizeof(u_int32_t)); // Set the number of nodes = -1 |
+ memset(data, 0xff, sizeof(uint32_t)); // Set the number of nodes = -1 |
test_map = TestMap(data); |
ASSERT_FALSE(test_map.ValidateInMemoryStructure()); |
} |
TEST_F(TestInvalidMap, TestWrongOffsets) { |
- u_int32_t* header = reinterpret_cast<u_int32_t*>(data); |
- const u_int32_t kNumNodes = 2; |
- const u_int32_t kHeaderOffset = |
- sizeof(u_int32_t) + kNumNodes * (sizeof(u_int32_t) + sizeof(KeyType)); |
+ uint32_t* header = reinterpret_cast<uint32_t*>(data); |
+ const uint32_t kNumNodes = 2; |
+ const uint32_t kHeaderOffset = |
+ sizeof(uint32_t) + kNumNodes * (sizeof(uint32_t) + sizeof(KeyType)); |
header[0] = kNumNodes; |
header[1] = kHeaderOffset + 3; // Wrong offset for first node |
test_map = TestMap(data); |
ASSERT_FALSE(test_map.ValidateInMemoryStructure()); |
header[1] = kHeaderOffset; // Correct offset for first node |
header[2] = kHeaderOffset - 1; // Wrong offset for second node |
test_map = TestMap(data); |
ASSERT_FALSE(test_map.ValidateInMemoryStructure()); |
} |
TEST_F(TestInvalidMap, TestUnSortedKeys) { |
- u_int32_t* header = reinterpret_cast<u_int32_t*>(data); |
- const u_int32_t kNumNodes = 2; |
- const u_int32_t kHeaderOffset = |
- sizeof(u_int32_t) + kNumNodes * (sizeof(u_int32_t) + sizeof(KeyType)); |
+ uint32_t* header = reinterpret_cast<uint32_t*>(data); |
+ const uint32_t kNumNodes = 2; |
+ const uint32_t kHeaderOffset = |
+ sizeof(uint32_t) + kNumNodes * (sizeof(uint32_t) + sizeof(KeyType)); |
header[0] = kNumNodes; |
header[1] = kHeaderOffset; |
header[2] = kHeaderOffset + sizeof(ValueType); |
KeyType* keys = reinterpret_cast<KeyType*>( |
- data + (kNumNodes + 1) * sizeof(u_int32_t)); |
+ data + (kNumNodes + 1) * sizeof(uint32_t)); |
// Set keys in non-increasing order. |
keys[0] = 10; |
keys[1] = 7; |
test_map = TestMap(data); |
ASSERT_FALSE(test_map.ValidateInMemoryStructure()); |
} |
@@ -166,20 +166,20 @@ class TestValidMap : public ::testing::T |
for (int i = 0; i < 1000; ++i) |
std_map[testcase].insert(std::make_pair(rand(), rand())); |
map_data[testcase] = |
serializer.Serialize(std_map[testcase], &size[testcase]); |
test_map[testcase] = TestMap(map_data[testcase]); |
// Set correct size of memory allocation for each test case. |
unsigned int size_per_node = |
- sizeof(u_int32_t) + sizeof(KeyType) + sizeof(ValueType); |
+ sizeof(uint32_t) + sizeof(KeyType) + sizeof(ValueType); |
for (testcase = 0; testcase < kNumberTestCases; ++testcase) { |
correct_size[testcase] = |
- sizeof(u_int32_t) + std_map[testcase].size() * size_per_node; |
+ sizeof(uint32_t) + std_map[testcase].size() * size_per_node; |
} |
} |
void TearDown() { |
for (int i = 0;i < kNumberTestCases; ++i) |
delete map_data[i]; |
} |