| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/debug/crash_logging.h" | 5 #include "base/debug/crash_logging.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 108 |
| 109 TEST_F(CrashLoggingTest, ScopedCrashKey) { | 109 TEST_F(CrashLoggingTest, ScopedCrashKey) { |
| 110 const char kTestKey[] = "test-key"; | 110 const char kTestKey[] = "test-key"; |
| 111 base::debug::CrashKey keys[] = { { kTestKey, 255 } }; | 111 base::debug::CrashKey keys[] = { { kTestKey, 255 } }; |
| 112 base::debug::InitCrashKeys(keys, arraysize(keys), 255); | 112 base::debug::InitCrashKeys(keys, arraysize(keys), 255); |
| 113 | 113 |
| 114 EXPECT_EQ(0u, key_values_->size()); | 114 EXPECT_EQ(0u, key_values_->size()); |
| 115 EXPECT_TRUE(key_values_->end() == key_values_->find(kTestKey)); | 115 EXPECT_TRUE(key_values_->end() == key_values_->find(kTestKey)); |
| 116 { | 116 { |
| 117 base::debug::ScopedCrashKey scoped_crash_key(kTestKey, "value"); | 117 base::debug::ScopedCrashKey scoped_crash_key(kTestKey, "value"); |
| 118 base::debug::ScopedCrashKey(kTestKey, "with no name"); |
| 118 EXPECT_EQ("value", (*key_values_)[kTestKey]); | 119 EXPECT_EQ("value", (*key_values_)[kTestKey]); |
| 119 EXPECT_EQ(1u, key_values_->size()); | 120 EXPECT_EQ(1u, key_values_->size()); |
| 120 } | 121 } |
| 121 EXPECT_EQ(0u, key_values_->size()); | 122 EXPECT_EQ(0u, key_values_->size()); |
| 122 EXPECT_TRUE(key_values_->end() == key_values_->find(kTestKey)); | 123 EXPECT_TRUE(key_values_->end() == key_values_->find(kTestKey)); |
| 123 } | 124 } |
| 124 | 125 |
| 125 TEST_F(CrashLoggingTest, InitSize) { | 126 TEST_F(CrashLoggingTest, InitSize) { |
| 126 base::debug::CrashKey keys[] = { | 127 base::debug::CrashKey keys[] = { |
| 127 { "chunked-3", 15 }, | 128 { "chunked-3", 15 }, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 EXPECT_EQ("wor", results[2]); | 177 EXPECT_EQ("wor", results[2]); |
| 177 EXPECT_EQ("ld", results[3]); | 178 EXPECT_EQ("ld", results[3]); |
| 178 } | 179 } |
| 179 | 180 |
| 180 TEST_F(CrashLoggingTest, ChunkRounding) { | 181 TEST_F(CrashLoggingTest, ChunkRounding) { |
| 181 // If max_length=12 and max_chunk_length=5, there should be 3 chunks, | 182 // If max_length=12 and max_chunk_length=5, there should be 3 chunks, |
| 182 // not 2. | 183 // not 2. |
| 183 base::debug::CrashKey key = { "round", 12 }; | 184 base::debug::CrashKey key = { "round", 12 }; |
| 184 EXPECT_EQ(3u, base::debug::InitCrashKeys(&key, 1, 5)); | 185 EXPECT_EQ(3u, base::debug::InitCrashKeys(&key, 1, 5)); |
| 185 } | 186 } |
| OLD | NEW |