1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc.  All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 //     * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //     * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 //     * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 // Author: kenton@google.com (Kenton Varda)
32 //  Based on original Protocol Buffers design by
33 //  Sanjay Ghemawat, Jeff Dean, and others.
34 
35 #ifndef GOOGLE_PROTOBUF_TEST_UTIL_LITE_H__
36 #define GOOGLE_PROTOBUF_TEST_UTIL_LITE_H__
37 
38 #include <google/protobuf/unittest_lite.pb.h>
39 
40 namespace google {
41 namespace protobuf {
42 
43 namespace unittest = protobuf_unittest;
44 namespace unittest_import = protobuf_unittest_import;
45 
46 class TestUtilLite {
47  public:
48   // Set every field in the message to a unique value.
49   static void SetAllFields(unittest::TestAllTypesLite* message);
50   static void SetAllExtensions(unittest::TestAllExtensionsLite* message);
51   static void SetPackedFields(unittest::TestPackedTypesLite* message);
52   static void SetPackedExtensions(unittest::TestPackedExtensionsLite* message);
53 
54   // Use the repeated versions of the set_*() accessors to modify all the
55   // repeated fields of the message (which should already have been
56   // initialized with Set*Fields()).  Set*Fields() itself only tests
57   // the add_*() accessors.
58   static void ModifyRepeatedFields(unittest::TestAllTypesLite* message);
59   static void ModifyRepeatedExtensions(
60       unittest::TestAllExtensionsLite* message);
61   static void ModifyPackedFields(unittest::TestPackedTypesLite* message);
62   static void ModifyPackedExtensions(
63       unittest::TestPackedExtensionsLite* message);
64 
65   // Check that all fields have the values that they should have after
66   // Set*Fields() is called.
67   static void ExpectAllFieldsSet(const unittest::TestAllTypesLite& message);
68   static void ExpectAllExtensionsSet(
69       const unittest::TestAllExtensionsLite& message);
70   static void ExpectPackedFieldsSet(
71       const unittest::TestPackedTypesLite& message);
72   static void ExpectPackedExtensionsSet(
73       const unittest::TestPackedExtensionsLite& message);
74 
75   // Expect that the message is modified as would be expected from
76   // Modify*Fields().
77   static void ExpectRepeatedFieldsModified(
78       const unittest::TestAllTypesLite& message);
79   static void ExpectRepeatedExtensionsModified(
80       const unittest::TestAllExtensionsLite& message);
81   static void ExpectPackedFieldsModified(
82       const unittest::TestPackedTypesLite& message);
83   static void ExpectPackedExtensionsModified(
84       const unittest::TestPackedExtensionsLite& message);
85 
86   // Check that all fields have their default values.
87   static void ExpectClear(const unittest::TestAllTypesLite& message);
88   static void ExpectExtensionsClear(
89       const unittest::TestAllExtensionsLite& message);
90   static void ExpectPackedClear(const unittest::TestPackedTypesLite& message);
91   static void ExpectPackedExtensionsClear(
92       const unittest::TestPackedExtensionsLite& message);
93 
94  private:
95   GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TestUtilLite);
96 };
97 
98 }  // namespace protobuf
99 
100 }  // namespace google
101 #endif  // GOOGLE_PROTOBUF_TEST_UTIL_LITE_H__
102