Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
parse_test_proto.h
Go to the documentation of this file.
1// Copyright 2010-2025 Google LLC
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14#ifndef OR_TOOLS_BASE_PARSE_TEST_PROTO_H_
15#define OR_TOOLS_BASE_PARSE_TEST_PROTO_H_
16
17#include <string>
18#include <string_view>
19
20#include "google/protobuf/message.h"
21#include "google/protobuf/text_format.h"
22#include "gtest/gtest.h"
23
25
27
29 public:
30 explicit ParseProtoHelper(std::string_view asciipb) : asciipb_(asciipb) {}
31 template <class T>
32 operator T() { // NOLINT(runtime/explicit)
33 T result;
34 const bool ok = google::protobuf::TextFormat::TextFormat::ParseFromString(
35 asciipb_, &result);
36 EXPECT_TRUE(ok) << "Failed to parse text proto: " << asciipb_;
37 return result;
38 }
39
40 private:
41 const std::string asciipb_;
42};
43
44} // namespace parse_proto_internal
45
49
50} // namespace google::protobuf::contrib::parse_proto
51
52#endif // OR_TOOLS_BASE_PARSE_TEST_PROTO_H_
parse_proto_internal::ParseProtoHelper ParseTestProto(std::string_view input)
static int input(yyscan_t yyscanner)