Fix Android sync regression as a result of https://codereview.chromium.org/1144543009
[chromium-blink-merge.git] / sync / syncable / syncable_enum_conversions_unittest.cc
blobd11d01747e60d9ec316705ddb0d3119ebe7606db
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.
5 // Keep this file in sync with entry_kernel.h.
7 #include "sync/syncable/syncable_enum_conversions.h"
9 #include <string>
11 #include "testing/gtest/include/gtest/gtest.h"
13 namespace syncer {
14 namespace syncable {
15 namespace {
17 class SyncableEnumConversionsTest : public testing::Test {
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());
30 TEST_F(SyncableEnumConversionsTest, GetMetahandleFieldString) {
31 TestEnumStringFunction(
32 GetMetahandleFieldString, INT64_FIELDS_BEGIN, META_HANDLE);
35 TEST_F(SyncableEnumConversionsTest, GetBaseVersionString) {
36 TestEnumStringFunction(
37 GetBaseVersionString, META_HANDLE + 1, BASE_VERSION);
40 TEST_F(SyncableEnumConversionsTest, GetInt64FieldString) {
41 TestEnumStringFunction(
42 GetInt64FieldString, BASE_VERSION + 1, INT64_FIELDS_END - 1);
45 TEST_F(SyncableEnumConversionsTest, GetTimeFieldString) {
46 TestEnumStringFunction(
47 GetTimeFieldString, TIME_FIELDS_BEGIN, TIME_FIELDS_END - 1);
50 TEST_F(SyncableEnumConversionsTest, GetIdFieldString) {
51 TestEnumStringFunction(
52 GetIdFieldString, ID_FIELDS_BEGIN, ID_FIELDS_END - 1);
55 TEST_F(SyncableEnumConversionsTest, GetIndexedBitFieldString) {
56 TestEnumStringFunction(
57 GetIndexedBitFieldString, BIT_FIELDS_BEGIN, INDEXED_BIT_FIELDS_END - 1);
60 TEST_F(SyncableEnumConversionsTest, GetIsDelFieldString) {
61 TestEnumStringFunction(
62 GetIsDelFieldString, INDEXED_BIT_FIELDS_END, IS_DEL);
65 TEST_F(SyncableEnumConversionsTest, GetBitFieldString) {
66 TestEnumStringFunction(
67 GetBitFieldString, IS_DEL + 1, BIT_FIELDS_END - 1);
70 TEST_F(SyncableEnumConversionsTest, GetStringFieldString) {
71 TestEnumStringFunction(
72 GetStringFieldString, STRING_FIELDS_BEGIN, STRING_FIELDS_END - 1);
75 TEST_F(SyncableEnumConversionsTest, GetProtoFieldString) {
76 TestEnumStringFunction(
77 GetProtoFieldString, PROTO_FIELDS_BEGIN, PROTO_FIELDS_END - 1);
80 TEST_F(SyncableEnumConversionsTest, GetUniquePositionFieldString) {
81 TestEnumStringFunction(
82 GetUniquePositionFieldString,
83 UNIQUE_POSITION_FIELDS_BEGIN, UNIQUE_POSITION_FIELDS_END - 1);
86 TEST_F(SyncableEnumConversionsTest, GetAttachmentMetadataFieldString) {
87 TestEnumStringFunction(
88 GetAttachmentMetadataFieldString,
89 ATTACHMENT_METADATA_FIELDS_BEGIN, ATTACHMENT_METADATA_FIELDS_END - 1);
92 TEST_F(SyncableEnumConversionsTest, GetBitTempString) {
93 TestEnumStringFunction(
94 GetBitTempString, BIT_TEMPS_BEGIN, BIT_TEMPS_END - 1);
97 } // namespace
98 } // namespace syncable
99 } // namespace syncer