| 10 | namespace { |
| 11 | |
| 12 | static bool registerProtoInDatabase(Protobuf::DescriptorDatabase& database, ExceptionTracker& exceptionTracker) { |
| 13 | std::string_view proto1 = R"( |
| 14 | syntax = "proto3"; |
| 15 | package test; |
| 16 | |
| 17 | enum Enum { |
| 18 | VALUE_0 = 0; |
| 19 | VALUE_1 = 1; |
| 20 | } |
| 21 | |
| 22 | message MyMessage { |
| 23 | string value = 1; |
| 24 | } |
| 25 | |
| 26 | message MapMessage { |
| 27 | map<string, string> stringToString = 1; |
| 28 | } |
| 29 | |
| 30 | message 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"( |
| 46 | syntax = "proto3"; |
| 47 | package other_package.nested; |
| 48 | |
| 49 | message 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 | |
| 65 | TEST(DescriptorDatabase, canFindFileByName) { |
| 66 | SimpleExceptionTracker exceptionTracker; |
no test coverage detected