• 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 #ifndef TEXT_FORMAT_CONFORMANCE_SUITE_H_
9 #define TEXT_FORMAT_CONFORMANCE_SUITE_H_
10 
11 #include <string>
12 
13 #include "conformance_test.h"
14 #include "google/protobuf/message.h"
15 
16 namespace google {
17 namespace protobuf {
18 
19 class TextFormatConformanceTestSuite : public ConformanceTestSuite {
20  public:
21   TextFormatConformanceTestSuite();
22 
23  private:
24   void RunSuiteImpl() override;
25 
26   bool ParseTextFormatResponse(const conformance::ConformanceResponse& response,
27                                const ConformanceRequestSetting& setting,
28                                Message* test_message);
29   bool ParseResponse(const conformance::ConformanceResponse& response,
30                      const ConformanceRequestSetting& setting,
31                      Message* test_message) override;
32 
33   template <typename MessageType>
34   friend class TextFormatConformanceTestSuiteImpl;
35 };
36 
37 template <typename MessageType>
38 class TextFormatConformanceTestSuiteImpl {
39  public:
40   explicit TextFormatConformanceTestSuiteImpl(
41       TextFormatConformanceTestSuite* suite);
42 
43  private:
44   using ConformanceRequestSetting =
45       TextFormatConformanceTestSuite::ConformanceRequestSetting;
46   using ConformanceLevel = TextFormatConformanceTestSuite::ConformanceLevel;
47   constexpr static ConformanceLevel RECOMMENDED = ConformanceLevel::RECOMMENDED;
48   constexpr static ConformanceLevel REQUIRED = ConformanceLevel::REQUIRED;
49 
50   void RunAllTests();
51 
52   void RunDelimitedTests();
53   void RunGroupTests();
54   void RunAnyTests();
55   void RunOpenEnumTests();
56   void RunClosedEnumTests();
57 
58   void RunTextFormatPerformanceTests();
59   void RunValidTextFormatTest(const std::string& test_name,
60                               ConformanceLevel level, const std::string& input);
61   void RunValidTextFormatTestWithExpected(const std::string& test_name,
62                                           ConformanceLevel level,
63                                           const std::string& input_text,
64                                           const std::string& expected_text);
65   void RunValidUnknownTextFormatTest(const std::string& test_name,
66                                      const Message& message);
67   void RunValidTextFormatTestWithMessage(const std::string& test_name,
68                                          ConformanceLevel level,
69                                          const std::string& input_text,
70                                          const Message& message);
71   void ExpectParseFailure(const std::string& test_name, ConformanceLevel level,
72                           const std::string& input);
73   void TestTextFormatPerformanceMergeMessageWithRepeatedField(
74       const std::string& test_type_name, const std::string& message_field);
75 
76   TextFormatConformanceTestSuite& suite_;
77 };
78 
79 }  // namespace protobuf
80 }  // namespace google
81 
82 #endif  // TEXT_FORMAT_CONFORMANCE_SUITE_H_
83