Changed parsing-conversion behaviour of the void value. It is now less strict.

This commit is contained in:
Leonetienne
2021-06-05 12:37:24 +02:00
parent d6145ea5a9
commit c18c7b1c74
4 changed files with 41 additions and 2 deletions

View File

@@ -307,8 +307,37 @@ namespace TestHazelnupp
nupp.Parse(C_Ify(args));
// Verify
Assert::IsTrue(nupp["--empty-list"].GetDataType() == DATA_TYPE::LIST);
Assert::AreEqual(std::size_t(0), nupp["--empty-list"].GetList().size());
Assert::IsTrue(nupp["--empty-list"].GetDataType() == DATA_TYPE::LIST, L"Wrong datatype");
Assert::AreEqual(std::size_t(0), nupp["--empty-list"].GetList().size(), L"Wrong size");
return;
}
// Tests that a void can be converted to an empty string
TEST_METHOD(Weird_Load_Conversions_VoidToEmptyString)
{
// Setup
ArgList args({
"/my/fake/path/wahoo.out",
"--dummy",
"--empty-string",
});
Hazelnupp nupp;
nupp.SetCrashOnFail(false);
nupp.RegisterConstraint(
"--empty-string",
ParamConstraint::TypeSafety(DATA_TYPE::STRING)
);
// Exercise
nupp.Parse(C_Ify(args));
// Verify
Assert::IsTrue(nupp["--empty-string"].GetDataType() == DATA_TYPE::STRING, L"Wrong datatype");
Assert::AreEqual(std::size_t(0), nupp["--empty-string"].GetString().length(), L"Wrong size");
return;
}