Skip to content

Commit

Permalink
More test data
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll committed Mar 8, 2024
1 parent 4f257e3 commit fbe8627
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
8 changes: 8 additions & 0 deletions test/desc/testing.invalid
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
syntax = "proto3";

package testing;

message Bytes
{
bytes data = 1;
}
8 changes: 8 additions & 0 deletions test/desc/testing.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
syntax = "proto3";

package testing;

message Bytes
{
bytes data = 1;
}
15 changes: 13 additions & 2 deletions test/integration/descriptors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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"));

}

0 comments on commit fbe8627

Please sign in to comment.