| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 EXPECT_EQ(dict.GetCount(), 3u); | 64 EXPECT_EQ(dict.GetCount(), 3u); |
| 65 // try an unknown key | 65 // try an unknown key |
| 66 EXPECT_FALSE(dict.GetValueForKey("key4")); | 66 EXPECT_FALSE(dict.GetValueForKey("key4")); |
| 67 | 67 |
| 68 // Remove a key | 68 // Remove a key |
| 69 dict.RemoveKey("key3"); | 69 dict.RemoveKey("key3"); |
| 70 | 70 |
| 71 // Now make sure it's not there anymore | 71 // Now make sure it's not there anymore |
| 72 EXPECT_FALSE(dict.GetValueForKey("key3")); | 72 EXPECT_FALSE(dict.GetValueForKey("key3")); |
| 73 | 73 |
| 74 // Remove by setting value to NULL | 74 // Remove by setting value to nullptr |
| 75 dict.SetKeyValue("key2", NULL); | 75 dict.SetKeyValue("key2", nullptr); |
| 76 | 76 |
| 77 // Now make sure it's not there anymore | 77 // Now make sure it's not there anymore |
| 78 EXPECT_FALSE(dict.GetValueForKey("key2")); | 78 EXPECT_FALSE(dict.GetValueForKey("key2")); |
| 79 } | 79 } |
| 80 | 80 |
| 81 TEST(SimpleStringDictionary, CopyAndAssign) { | 81 TEST(SimpleStringDictionary, CopyAndAssign) { |
| 82 TSimpleStringDictionary<10, 10, 10> map; | 82 TSimpleStringDictionary<10, 10, 10> map; |
| 83 map.SetKeyValue("one", "a"); | 83 map.SetKeyValue("one", "a"); |
| 84 map.SetKeyValue("two", "b"); | 84 map.SetKeyValue("two", "b"); |
| 85 map.SetKeyValue("three", "c"); | 85 map.SetKeyValue("three", "c"); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 map.SetKeyValue("b", "2"); | 272 map.SetKeyValue("b", "2"); |
| 273 map.SetKeyValue("c", "3"); | 273 map.SetKeyValue("c", "3"); |
| 274 EXPECT_EQ(2u, map.GetCount()); | 274 EXPECT_EQ(2u, map.GetCount()); |
| 275 EXPECT_FALSE(map.GetValueForKey("c")); | 275 EXPECT_FALSE(map.GetValueForKey("c")); |
| 276 } | 276 } |
| 277 | 277 |
| 278 #if DCHECK_IS_ON | 278 #if DCHECK_IS_ON |
| 279 | 279 |
| 280 TEST(SimpleStringDictionaryDeathTest, NullKey) { | 280 TEST(SimpleStringDictionaryDeathTest, NullKey) { |
| 281 TSimpleStringDictionary<4, 6, 6> map; | 281 TSimpleStringDictionary<4, 6, 6> map; |
| 282 ASSERT_DEATH(map.SetKeyValue(NULL, "hello"), "key"); | 282 ASSERT_DEATH(map.SetKeyValue(nullptr, "hello"), "key"); |
| 283 | 283 |
| 284 map.SetKeyValue("hi", "there"); | 284 map.SetKeyValue("hi", "there"); |
| 285 ASSERT_DEATH(map.GetValueForKey(NULL), "key"); | 285 ASSERT_DEATH(map.GetValueForKey(nullptr), "key"); |
| 286 EXPECT_STREQ("there", map.GetValueForKey("hi")); | 286 EXPECT_STREQ("there", map.GetValueForKey("hi")); |
| 287 | 287 |
| 288 ASSERT_DEATH(map.GetValueForKey(NULL), "key"); | 288 ASSERT_DEATH(map.GetValueForKey(nullptr), "key"); |
| 289 map.RemoveKey("hi"); | 289 map.RemoveKey("hi"); |
| 290 EXPECT_EQ(0u, map.GetCount()); | 290 EXPECT_EQ(0u, map.GetCount()); |
| 291 } | 291 } |
| 292 | 292 |
| 293 #endif | 293 #endif |
| 294 | 294 |
| 295 } // namespace | 295 } // namespace |
| 296 } // namespace test | 296 } // namespace test |
| 297 } // namespace crashpad | 297 } // namespace crashpad |
| OLD | NEW |