From fbe8627911c4f97f790dc599cc004dd9d5e6b529 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Fri, 8 Mar 2024 20:33:23 +0000 Subject: [PATCH] More test data Signed-off-by: Michael Carroll --- test/desc/testing.invalid | 8 ++++++++ test/desc/testing.proto | 8 ++++++++ test/integration/descriptors.cc | 15 +++++++++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 test/desc/testing.invalid 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")); - }