Skip to content

Commit

Permalink
Add core utility unit tests
Browse files Browse the repository at this point in the history
This changelist adds a handful of new unit tests for core utilities, bringing the measured code coverage of MaterialX unit tests to 88.4%.
  • Loading branch information
jstone-lucasfilm committed Apr 7, 2024
1 parent a966b8d commit d58302b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions source/MaterialXTest/MaterialXCore/CoreUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ TEST_CASE("String utilities", "[coreutil]")

REQUIRE(mx::splitString("robot1, robot2", ", ") == (std::vector<std::string>{"robot1", "robot2"}));
REQUIRE(mx::splitString("[one...two...three]", "[.]") == (std::vector<std::string>{"one", "two", "three"}));

REQUIRE(mx::stringToLower("testName") == "testname");
REQUIRE(mx::stringToLower("testName1") == "testname1");

REQUIRE(mx::stringStartsWith("testName", "test"));
REQUIRE(!mx::stringStartsWith("testName", "Name"));
REQUIRE(mx::stringEndsWith("testName", "Name"));
REQUIRE(!mx::stringEndsWith("testName", "test"));
}

TEST_CASE("Print utilities", "[coreutil]")
Expand Down
7 changes: 7 additions & 0 deletions source/MaterialXTest/MaterialXCore/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ TEST_CASE("Document", "[document]")
// Create a document.
mx::DocumentPtr doc = mx::createDocument();

// Test version strings.
REQUIRE(mx::stringStartsWith(mx::getVersionString(), doc->getVersionString()));

// Test version integers.
REQUIRE(doc->getVersionIntegers().first == std::get<0>(mx::getVersionIntegers()));
REQUIRE(doc->getVersionIntegers().second == std::get<1>(mx::getVersionIntegers()));

// Create a node graph with a constant color output.
mx::NodeGraphPtr nodeGraph = doc->addNodeGraph();
mx::NodePtr constant = nodeGraph->addNode("constant");
Expand Down

0 comments on commit d58302b

Please sign in to comment.