| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "sync/internal_api/public/util/proto_value_ptr.h" | 5 #include "sync/internal_api/public/util/proto_value_ptr.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/macros.h" | 9 #include "base/macros.h" |
| 8 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 12 |
| 11 namespace syncer { | 13 namespace syncer { |
| 12 | 14 |
| 13 namespace { | 15 namespace { |
| 14 | 16 |
| 15 // Simple test struct that wraps an integer | 17 // Simple test struct that wraps an integer |
| 16 struct IntValue { | 18 struct IntValue { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 65 |
| 64 void Swap(TestValue* src) { | 66 void Swap(TestValue* src) { |
| 65 // Expected to always swap with an initialized instance. | 67 // Expected to always swap with an initialized instance. |
| 66 // The current instance must always be an uninitialized one. | 68 // The current instance must always be an uninitialized one. |
| 67 // Not expected either value to be default. | 69 // Not expected either value to be default. |
| 68 ASSERT_FALSE(is_initialized()); | 70 ASSERT_FALSE(is_initialized()); |
| 69 ASSERT_FALSE(is_default()); | 71 ASSERT_FALSE(is_default()); |
| 70 ASSERT_TRUE(src->is_initialized()); | 72 ASSERT_TRUE(src->is_initialized()); |
| 71 ASSERT_FALSE(src->is_default()); | 73 ASSERT_FALSE(src->is_default()); |
| 72 // Not exactly swap, but good enough for the test. | 74 // Not exactly swap, but good enough for the test. |
| 73 value_ = src->value_.Pass(); | 75 value_ = std::move(src->value_); |
| 74 } | 76 } |
| 75 | 77 |
| 76 void ParseFromArray(const void* blob, int length) { | 78 void ParseFromArray(const void* blob, int length) { |
| 77 // Similarly to CopyFrom this is expected to be called on | 79 // Similarly to CopyFrom this is expected to be called on |
| 78 // an uninitialized instance. | 80 // an uninitialized instance. |
| 79 ASSERT_FALSE(is_initialized()); | 81 ASSERT_FALSE(is_initialized()); |
| 80 ASSERT_FALSE(is_default()); | 82 ASSERT_FALSE(is_default()); |
| 81 // The blob is an address of an integer | 83 // The blob is an address of an integer |
| 82 ASSERT_EQ(static_cast<int>(sizeof(int)), length); | 84 ASSERT_EQ(static_cast<int>(sizeof(int)), length); |
| 83 value_.reset(new IntValue(*static_cast<const int*>(blob))); | 85 value_.reset(new IntValue(*static_cast<const int*>(blob))); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 EXPECT_EQ(1, TestValue::parse_count()); | 240 EXPECT_EQ(1, TestValue::parse_count()); |
| 239 EXPECT_EQ(0, TestValue::copy_count()); | 241 EXPECT_EQ(0, TestValue::copy_count()); |
| 240 | 242 |
| 241 EXPECT_EQ(v1, ptr1->value()); | 243 EXPECT_EQ(v1, ptr1->value()); |
| 242 } | 244 } |
| 243 | 245 |
| 244 EXPECT_EQ(1, TestValue::delete_count()); | 246 EXPECT_EQ(1, TestValue::delete_count()); |
| 245 } | 247 } |
| 246 | 248 |
| 247 } // namespace syncer | 249 } // namespace syncer |
| OLD | NEW |