-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9da015b
commit 1678128
Showing
3 changed files
with
74 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include "google/protobuf/any_test.pb.hpp" | ||
#include <google/protobuf/field_mask.pb.hpp> | ||
#include "non_owning/google/protobuf/any_test.pb.hpp" | ||
#include "non_owning/google/protobuf/field_mask.pb.hpp" | ||
|
||
#include <boost/ut.hpp> | ||
#include "test_util.h" | ||
|
||
using namespace boost::ut; | ||
|
||
suite test_any = [] { | ||
"any"_test = [] { | ||
protobuf_unittest::TestAny message; | ||
google::protobuf::FieldMask fm{.paths = {"/usr/share", "/usr/local/share"}}; | ||
expect(hpp::proto::pack_any(message.any_value.emplace(), fm).success()); | ||
|
||
std::vector<char> buf; | ||
expect(hpp::proto::write_proto(message, buf).success()); | ||
|
||
protobuf_unittest::TestAny message2; | ||
expect(hpp::proto::read_proto(message2, buf).success()); | ||
google::protobuf::FieldMask fm2; | ||
expect(hpp::proto::unpack_any(message2.any_value.value(), fm2).success()); | ||
expect(fm == fm2); | ||
}; | ||
|
||
"non_owning_any"_test = [] { | ||
using namespace std::string_view_literals; | ||
|
||
monotonic_buffer_resource mr{1024}; | ||
|
||
non_owning::protobuf_unittest::TestAny message; | ||
std::array<std::string_view, 2> paths{"/usr/share"sv, "/usr/local/share"sv}; | ||
non_owning::google::protobuf::FieldMask fm{.paths = paths}; | ||
expect(hpp::proto::pack_any(message.any_value.emplace(), fm, mr).success()); | ||
|
||
std::vector<char> buf; | ||
expect(hpp::proto::write_proto(message, buf).success()); | ||
|
||
non_owning::protobuf_unittest::TestAny message2; | ||
expect(hpp::proto::read_proto(message2, buf, mr).success()); | ||
non_owning::google::protobuf::FieldMask fm2; | ||
expect(hpp::proto::unpack_any(message2.any_value.value(), fm2, mr).success()); | ||
expect(std::ranges::equal(paths, fm2.paths)); | ||
}; | ||
}; | ||
|
||
int main() { | ||
const auto result = boost::ut::cfg<>.run({.report_errors = true}); // explicitly run registered test suites and report errors | ||
return static_cast<int>(result); | ||
} |