diff --git a/test/desc/testing.invalid b/test/desc/testing.invalid new file mode 100644 index 00000000..b2524164 --- /dev/null +++ b/test/desc/testing.invalid @@ -0,0 +1,8 @@ +syntax = "proto3"; + +package testing; + +message Bytes +{ + bytes data = 1; +} diff --git a/test/desc/testing.proto b/test/desc/testing.proto index e69de29b..b2524164 100644 --- a/test/desc/testing.proto +++ b/test/desc/testing.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; + +package testing; + +message Bytes +{ + bytes data = 1; +} diff --git a/test/integration/descriptors.cc b/test/integration/descriptors.cc index 6d38b969..2d7ee0d5 100644 --- a/test/integration/descriptors.cc +++ b/test/integration/descriptors.cc @@ -43,7 +43,19 @@ TEST(FactoryTest, DynamicFactory) EXPECT_EQ(nullptr, gz::msgs::Factory::New("testing.BarMessage")); EXPECT_EQ(nullptr, gz::msgs::Factory::New("testing.BazMessage")); - // Test loading an empty file + // Test loading an incorrect extension + { + std::filesystem::path test_path(kMsgsTestPath); + std::string paths = (test_path / "desc" / "testing.invalid").string(); + gz::msgs::Factory::LoadDescriptors(paths); + } + EXPECT_EQ(nullptr, gz::msgs::Factory::New("example.msgs.StringMsg")); + EXPECT_EQ(nullptr, gz::msgs::Factory::New("testing.Bytes")); + EXPECT_EQ(nullptr, gz::msgs::Factory::New("testing.FooMessage")); + EXPECT_EQ(nullptr, gz::msgs::Factory::New("testing.BarMessage")); + EXPECT_EQ(nullptr, gz::msgs::Factory::New("testing.BazMessage")); + + // Test loading a file with invalid content { std::filesystem::path test_path(kMsgsTestPath); std::string paths = (test_path / "desc" / "testing.proto").string(); @@ -80,5 +92,4 @@ TEST(FactoryTest, DynamicFactory) EXPECT_NE(nullptr, gz::msgs::Factory::New("testing.FooMessage")); EXPECT_NE(nullptr, gz::msgs::Factory::New("testing.BarMessage")); EXPECT_NE(nullptr, gz::msgs::Factory::New("testing.BazMessage")); - }