OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Keep this file in sync with entry_kernel.h. | |
6 | |
7 #include "sync/syncable/syncable_enum_conversions.h" | |
8 | |
9 #include <string> | |
10 | |
11 #include "testing/gtest/include/gtest/gtest.h" | |
12 | |
13 namespace syncer { | |
14 namespace syncable { | |
15 namespace { | |
16 | |
17 class SyncableEnumConversionsTest : public testing::Test { | |
18 }; | |
19 | |
20 template <class T> | |
21 void TestEnumStringFunction(const char* (*enum_string_fn)(T), | |
22 int enum_min, int enum_max) { | |
23 EXPECT_LE(enum_min, enum_max); | |
24 for (int i = enum_min; i <= enum_max; ++i) { | |
25 const std::string& str = enum_string_fn(static_cast<T>(i)); | |
26 EXPECT_FALSE(str.empty()); | |
27 } | |
28 } | |
29 | |
30 TEST_F(SyncableEnumConversionsTest, GetMetahandleFieldString) { | |
31 TestEnumStringFunction( | |
32 GetMetahandleFieldString, INT64_FIELDS_BEGIN, META_HANDLE); | |
33 } | |
34 | |
35 TEST_F(SyncableEnumConversionsTest, GetBaseVersionString) { | |
36 TestEnumStringFunction( | |
37 GetBaseVersionString, META_HANDLE + 1, BASE_VERSION); | |
38 } | |
39 | |
40 TEST_F(SyncableEnumConversionsTest, GetInt64FieldString) { | |
41 TestEnumStringFunction( | |
42 GetInt64FieldString, BASE_VERSION + 1, INT64_FIELDS_END - 1); | |
43 } | |
44 | |
45 TEST_F(SyncableEnumConversionsTest, GetTimeFieldString) { | |
46 TestEnumStringFunction( | |
47 GetTimeFieldString, TIME_FIELDS_BEGIN, TIME_FIELDS_END - 1); | |
48 } | |
49 | |
50 TEST_F(SyncableEnumConversionsTest, GetIdFieldString) { | |
51 TestEnumStringFunction( | |
52 GetIdFieldString, ID_FIELDS_BEGIN, ID_FIELDS_END - 1); | |
53 } | |
54 | |
55 TEST_F(SyncableEnumConversionsTest, GetIndexedBitFieldString) { | |
56 TestEnumStringFunction( | |
57 GetIndexedBitFieldString, BIT_FIELDS_BEGIN, INDEXED_BIT_FIELDS_END - 1); | |
58 } | |
59 | |
60 TEST_F(SyncableEnumConversionsTest, GetIsDelFieldString) { | |
61 TestEnumStringFunction( | |
62 GetIsDelFieldString, INDEXED_BIT_FIELDS_END, IS_DEL); | |
63 } | |
64 | |
65 TEST_F(SyncableEnumConversionsTest, GetBitFieldString) { | |
66 TestEnumStringFunction( | |
67 GetBitFieldString, IS_DEL + 1, BIT_FIELDS_END - 1); | |
68 } | |
69 | |
70 TEST_F(SyncableEnumConversionsTest, GetStringFieldString) { | |
71 TestEnumStringFunction( | |
72 GetStringFieldString, STRING_FIELDS_BEGIN, STRING_FIELDS_END - 1); | |
73 } | |
74 | |
75 TEST_F(SyncableEnumConversionsTest, GetProtoFieldString) { | |
76 TestEnumStringFunction( | |
77 GetProtoFieldString, PROTO_FIELDS_BEGIN, PROTO_FIELDS_END - 1); | |
78 } | |
79 | |
80 TEST_F(SyncableEnumConversionsTest, GetUniquePositionFieldString) { | |
81 TestEnumStringFunction( | |
82 GetUniquePositionFieldString, | |
83 UNIQUE_POSITION_FIELDS_BEGIN, UNIQUE_POSITION_FIELDS_END - 1); | |
84 } | |
85 | |
86 TEST_F(SyncableEnumConversionsTest, GetAttachmentMetadataFieldString) { | |
87 TestEnumStringFunction( | |
88 GetAttachmentMetadataFieldString, | |
89 ATTACHMENT_METADATA_FIELDS_BEGIN, ATTACHMENT_METADATA_FIELDS_END - 1); | |
90 } | |
91 | |
92 TEST_F(SyncableEnumConversionsTest, GetBitTempString) { | |
93 TestEnumStringFunction( | |
94 GetBitTempString, BIT_TEMPS_BEGIN, BIT_TEMPS_END - 1); | |
95 } | |
96 | |
97 } // namespace | |
98 } // namespace syncable | |
99 } // namespace syncer | |
OLD | NEW |