• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc.  All rights reserved.
3 //
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file or at
6 // https://developers.google.com/open-source/licenses/bsd
7 
8 // Author: kenton@google.com (Kenton Varda)
9 //  Based on original Protocol Buffers design by
10 //  Sanjay Ghemawat, Jeff Dean, and others.
11 
12 #ifndef GOOGLE_PROTOBUF_TEST_UTIL_LITE_H__
13 #define GOOGLE_PROTOBUF_TEST_UTIL_LITE_H__
14 
15 #include "google/protobuf/unittest_lite.pb.h"
16 
17 namespace google {
18 namespace protobuf {
19 
20 namespace unittest = protobuf_unittest;
21 namespace unittest_import = protobuf_unittest_import;
22 
23 class TestUtilLite {
24  public:
25   TestUtilLite() = delete;
26 
27   // Set every field in the message to a unique value.
28   static void SetAllFields(unittest::TestAllTypesLite* message);
29   static void SetAllExtensions(unittest::TestAllExtensionsLite* message);
30   static void SetPackedFields(unittest::TestPackedTypesLite* message);
31   static void SetPackedExtensions(unittest::TestPackedExtensionsLite* message);
32 
33   // Use the repeated versions of the set_*() accessors to modify all the
34   // repeated fields of the message (which should already have been
35   // initialized with Set*Fields()).  Set*Fields() itself only tests
36   // the add_*() accessors.
37   static void ModifyRepeatedFields(unittest::TestAllTypesLite* message);
38   static void ModifyRepeatedExtensions(
39       unittest::TestAllExtensionsLite* message);
40   static void ModifyPackedFields(unittest::TestPackedTypesLite* message);
41   static void ModifyPackedExtensions(
42       unittest::TestPackedExtensionsLite* message);
43 
44   // Check that all fields have the values that they should have after
45   // Set*Fields() is called.
46   static void ExpectAllFieldsSet(const unittest::TestAllTypesLite& message);
47   static void ExpectAllExtensionsSet(
48       const unittest::TestAllExtensionsLite& message);
49   static void ExpectPackedFieldsSet(
50       const unittest::TestPackedTypesLite& message);
51   static void ExpectPackedExtensionsSet(
52       const unittest::TestPackedExtensionsLite& message);
53 
54   // Expect that the message is modified as would be expected from
55   // Modify*Fields().
56   static void ExpectRepeatedFieldsModified(
57       const unittest::TestAllTypesLite& message);
58   static void ExpectRepeatedExtensionsModified(
59       const unittest::TestAllExtensionsLite& message);
60   static void ExpectPackedFieldsModified(
61       const unittest::TestPackedTypesLite& message);
62   static void ExpectPackedExtensionsModified(
63       const unittest::TestPackedExtensionsLite& message);
64 
65   // Check that all fields have their default values.
66   static void ExpectClear(const unittest::TestAllTypesLite& message);
67   static void ExpectExtensionsClear(
68       const unittest::TestAllExtensionsLite& message);
69   static void ExpectPackedClear(const unittest::TestPackedTypesLite& message);
70   static void ExpectPackedExtensionsClear(
71       const unittest::TestPackedExtensionsLite& message);
72 };
73 
74 }  // namespace protobuf
75 }  // namespace google
76 
77 #endif  // GOOGLE_PROTOBUF_TEST_UTIL_LITE_H__
78