1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-04-30 12:43:52 +00:00

Adding more ini tests, fix extra print

This commit is contained in:
Henry Fredrick Schreiner 2017-03-17 13:03:39 -04:00
parent 21f9159750
commit ead1ff0565
2 changed files with 63 additions and 1 deletions

View File

@ -826,7 +826,6 @@ protected:
detail::ini_ret_t& current = args.back();
std::string parent = current.parent(); // respects curent.level
std::string name = current.name();
std::cout << current.fullname << " " << parent << " " << name << std::endl;
// If a parent is listed, go to a subcommand
if(parent != "") {

View File

@ -325,6 +325,69 @@ TEST_F(TApp, IniLayered) {
}
TEST_F(TApp, IniFailure) {
TempFile tmpini{"TestIniTmp.ini"};
app.add_config("--config", tmpini);
{
std::ofstream out{tmpini};
out << "[default]" << std::endl;
out << "val=1" << std::endl;
}
EXPECT_THROW(run(), CLI::ExtrasINIError);
}
TEST_F(TApp, IniSubFailure) {
TempFile tmpini{"TestIniTmp.ini"};
auto sub = app.add_subcommand("other");
app.add_config("--config", tmpini);
{
std::ofstream out{tmpini};
out << "[other]" << std::endl;
out << "val=1" << std::endl;
}
EXPECT_THROW(run(), CLI::ExtrasINIError);
}
TEST_F(TApp, IniNoSubFailure) {
TempFile tmpini{"TestIniTmp.ini"};
app.add_config("--config", tmpini);
{
std::ofstream out{tmpini};
out << "[other]" << std::endl;
out << "val=1" << std::endl;
}
EXPECT_THROW(run(), CLI::ExtrasINIError);
}
TEST_F(TApp, IniFlagConvertFailure) {
TempFile tmpini{"TestIniTmp.ini"};
app.add_flag("--flag");
app.add_config("--config", tmpini);
{
std::ofstream out{tmpini};
out << "flag=moobook" << std::endl;
}
EXPECT_THROW(run(), CLI::ConversionError);
}
TEST_F(TApp, IniFlags) {
TempFile tmpini{"TestIniTmp.ini"};
app.add_config("--config", tmpini);