mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-04-30 20:53:52 +00:00
Adding more ini tests, fix extra print
This commit is contained in:
parent
21f9159750
commit
ead1ff0565
@ -826,7 +826,6 @@ protected:
|
|||||||
detail::ini_ret_t& current = args.back();
|
detail::ini_ret_t& current = args.back();
|
||||||
std::string parent = current.parent(); // respects curent.level
|
std::string parent = current.parent(); // respects curent.level
|
||||||
std::string name = current.name();
|
std::string name = current.name();
|
||||||
std::cout << current.fullname << " " << parent << " " << name << std::endl;
|
|
||||||
|
|
||||||
// If a parent is listed, go to a subcommand
|
// If a parent is listed, go to a subcommand
|
||||||
if(parent != "") {
|
if(parent != "") {
|
||||||
|
@ -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) {
|
TEST_F(TApp, IniFlags) {
|
||||||
TempFile tmpini{"TestIniTmp.ini"};
|
TempFile tmpini{"TestIniTmp.ini"};
|
||||||
app.add_config("--config", tmpini);
|
app.add_config("--config", tmpini);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user