| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "platform/json/JSONValues.h" | 5 #include "platform/json/JSONValues.h" |
| 6 | 6 |
| 7 #include "platform/wtf/text/StringBuilder.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "wtf/text/StringBuilder.h" | |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 class JSONValueDeletionVerifier : public JSONValue { | 14 class JSONValueDeletionVerifier : public JSONValue { |
| 15 public: | 15 public: |
| 16 JSONValueDeletionVerifier(int& counter) : m_counter(counter) {} | 16 JSONValueDeletionVerifier(int& counter) : m_counter(counter) {} |
| 17 | 17 |
| 18 ~JSONValueDeletionVerifier() override { ++m_counter; } | 18 ~JSONValueDeletionVerifier() override { ++m_counter; } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 TEST(JSONValuesTest, ObjectCastDoesNotLeak) { | 34 TEST(JSONValuesTest, ObjectCastDoesNotLeak) { |
| 35 int deletionCount = 0; | 35 int deletionCount = 0; |
| 36 std::unique_ptr<JSONValueDeletionVerifier> notAnObject( | 36 std::unique_ptr<JSONValueDeletionVerifier> notAnObject( |
| 37 new JSONValueDeletionVerifier(deletionCount)); | 37 new JSONValueDeletionVerifier(deletionCount)); |
| 38 EXPECT_EQ(nullptr, JSONArray::from(std::move(notAnObject))); | 38 EXPECT_EQ(nullptr, JSONArray::from(std::move(notAnObject))); |
| 39 EXPECT_EQ(1, deletionCount); | 39 EXPECT_EQ(1, deletionCount); |
| 40 } | 40 } |
| 41 | 41 |
| 42 } // namespace blink | 42 } // namespace blink |
| OLD | NEW |