MCPcopy Create free account
hub / github.com/Snapchat/Valdi / registerProtoInDatabase

Function registerProtoInDatabase

valdi_protobuf/test/DescriptorDatabase_tests.cpp:12–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10namespace {
11
12static bool registerProtoInDatabase(Protobuf::DescriptorDatabase& database, ExceptionTracker& exceptionTracker) {
13 std::string_view proto1 = R"(
14syntax = "proto3";
15package test;
16
17enum Enum {
18 VALUE_0 = 0;
19 VALUE_1 = 1;
20}
21
22message MyMessage {
23 string value = 1;
24}
25
26message MapMessage {
27 map<string, string> stringToString = 1;
28}
29
30message ParentMessage {
31 ChildMessage child_message = 1;
32 ChildEnum child_enum = 2;
33
34 message ChildMessage {
35 string value = 1;
36 }
37
38 enum ChildEnum {
39 VALUE_0 = 0;
40 VALUE_1 = 1;
41 }
42}
43)";
44
45 std::string_view proto2 = R"(
46syntax = "proto3";
47package other_package.nested;
48
49message MyOtherMessage {
50 string value = 1;
51}
52
53)";
54 if (!database.parseAndAddFileDescriptorSet("file1.proto", proto1, exceptionTracker)) {
55 return false;
56 }
57
58 if (!database.parseAndAddFileDescriptorSet("directory/file2.proto", proto2, exceptionTracker)) {
59 return false;
60 }
61
62 return true;
63}
64
65TEST(DescriptorDatabase, canFindFileByName) {
66 SimpleExceptionTracker exceptionTracker;

Callers 1

TESTFunction · 0.85

Calls 1

Tested by

no test coverage detected