Skip to content

Commit

Permalink
Add tests for shell-style variable expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-goode committed May 9, 2024
1 parent 06e8f09 commit aed770e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/libdnf/conf/ConfigParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,21 @@ void ConfigParserTest::testConfigParserReleasever()
libdnf::ConfigParser::substitute(text, substitutions);
CPPUNIT_ASSERT(text == "major: , minor: ");
}
{
std::map<std::string, std::string> substitutions = {
{"var1", "value123"},
{"var2", "456"},
};
std::string text = "foo$var1-bar";
libdnf::ConfigParser::substitute(text, substitutions);
CPPUNIT_ASSERT(text == "foovalue123-bar");

text = "${var1:+alternate}-${unset:-default}-${nn:+n${nn:-${nnn:}";
libdnf::ConfigParser::substitute(text, substitutions);
CPPUNIT_ASSERT(text == "alternate-default-${nn:+n${nn:-${nnn:}");

text = "${unset:-${var1:+${var2:+$var2}}}";
libdnf::ConfigParser::substitute(text, substitutions);
CPPUNIT_ASSERT(text == "456");
}
}

0 comments on commit aed770e

Please sign in to comment.