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> | 7 #include <utility> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 g_parse_count = 0; | 38 g_parse_count = 0; |
39 g_delete_count = 0; | 39 g_delete_count = 0; |
40 } | 40 } |
41 | 41 |
42 static int copy_count() { return g_copy_count; } | 42 static int copy_count() { return g_copy_count; } |
43 static int parse_count() { return g_parse_count; } | 43 static int parse_count() { return g_parse_count; } |
44 static int delete_count() { return g_delete_count; } | 44 static int delete_count() { return g_delete_count; } |
45 | 45 |
46 int value() const { return value_->value(); } | 46 int value() const { return value_->value(); } |
47 IntValue* value_ptr() const { return value_.get(); } | 47 IntValue* value_ptr() const { return value_.get(); } |
48 bool is_initialized() const { return value_; } | 48 bool is_initialized() const { return !!value_; } |
49 bool is_default() const { return is_default_; } | 49 bool is_default() const { return is_default_; } |
50 | 50 |
51 // TestValue uses the default traits struct with ProtoValuePtr<TestValue>. | 51 // TestValue uses the default traits struct with ProtoValuePtr<TestValue>. |
52 // The following 4 functions are expected by the traits struct to exist | 52 // The following 4 functions are expected by the traits struct to exist |
53 // in this class. | 53 // in this class. |
54 void CopyFrom(const TestValue& from) { | 54 void CopyFrom(const TestValue& from) { |
55 // Expected to always copy from an initialized instance | 55 // Expected to always copy from an initialized instance |
56 // to an uninitialized one. | 56 // to an uninitialized one. |
57 // Not expected either value to be default. | 57 // Not expected either value to be default. |
58 ASSERT_FALSE(is_initialized()); | 58 ASSERT_FALSE(is_initialized()); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 EXPECT_EQ(1, TestValue::parse_count()); | 239 EXPECT_EQ(1, TestValue::parse_count()); |
240 EXPECT_EQ(0, TestValue::copy_count()); | 240 EXPECT_EQ(0, TestValue::copy_count()); |
241 | 241 |
242 EXPECT_EQ(v1, ptr1->value()); | 242 EXPECT_EQ(v1, ptr1->value()); |
243 } | 243 } |
244 | 244 |
245 EXPECT_EQ(1, TestValue::delete_count()); | 245 EXPECT_EQ(1, TestValue::delete_count()); |
246 } | 246 } |
247 | 247 |
248 } // namespace syncer | 248 } // namespace syncer |
OLD | NEW |