Skip to content

Commit

Permalink
Add unittest for EmbeddedSpec for non-existing mappings
Browse files Browse the repository at this point in the history
this uses internal functions from GoogleTests
to capture the stderr message but according to the documentation
it should be fine to use them:
// All macros ending with _ and symbols defined in an
// internal namespace are subject to change without notice.  Code
// outside Google Test MUST NOT USE THEM DIRECTLY.  Macros that don't
// end with _ are part of Google Test's public API and can be used by
// code outside Google Test.
see https://github.com/google/googletest/blob/main/googletest/include/gtest/internal/gtest-port.h

Signed-off-by: Bi0T1N <Bi0T1N@users.noreply.github.com>
  • Loading branch information
Bi0T1N committed Jul 1, 2022
1 parent 66e5b3d commit 0433771
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/SDF_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,26 @@ TEST(SDF, EmbeddedSpec)
EXPECT_NE(result.find("name=\"version\" type=\"string\""), std::string::npos);
}

TEST(SDF, EmbeddedSpecNonExistent)
{
std::string result;
std::string output;

testing::internal::CaptureStderr();
result = sdf::SDF::EmbeddedSpec("unavailable.sdf", false);
output = testing::internal::GetCapturedStderr();
EXPECT_NE(output.find("Unable to find SDF filename"), std::string::npos);
EXPECT_NE(output.find("with version"), std::string::npos);
EXPECT_TRUE(result.empty());

output = "";
testing::internal::CaptureStderr();
result = sdf::SDF::EmbeddedSpec("unavailable.sdf", true);
output = testing::internal::GetCapturedStderr();
EXPECT_TRUE(output.empty());
EXPECT_TRUE(result.empty());
}

/////////////////////////////////////////////////
TEST(SDF, FilePath)
{
Expand Down

0 comments on commit 0433771

Please sign in to comment.