auto tokens = gmx::splitAndTrimDelimitedString(line, '=');
if (tokens.size() < 2)
{
- // TODO this seems like it silently ignores the user accidentally deleting an equals sign...
- if (debug)
- {
- fprintf(debug, "No = on line %d in file %s, ignored\n", indexOfLineReadFromFile, fn);
- }
+ auto message = gmx::formatString("No '=' to separate .mdp parameter key and value was found on line:\n'%s'", line.c_str());
+ warning_error(wi, message);
continue;
}
if (tokens.size() > 2)
auto firstEqualsPos = line.find('=');
tokens.emplace_back(gmx::stripString(line.substr(firstEqualsPos + 1)));
}
+ GMX_RELEASE_ASSERT(tokens.size() == 2, "Must have tokens for key and value");
+ if (tokens[0].empty() && tokens[1].empty())
+ {
+ auto message = gmx::formatString("No .mdp parameter name or value was found on line:\n'%s'", line.c_str());
+ warning_error(wi, message);
+ continue;
+ }
if (tokens[0].empty())
{
- // TODO ignoring such lines does not seem like good behaviour
- if (debug)
- {
- fprintf(debug, "Empty left hand side on line %d in file %s, ignored\n", indexOfLineReadFromFile, fn);
- }
+ auto message = gmx::formatString("No .mdp parameter name was found on the left-hand side of '=' on line:\n'%s'", line.c_str());
+ warning_error(wi, message);
continue;
}
if (tokens[1].empty())
{
- // TODO ignoring such lines does not seem like good behaviour
- if (debug)
- {
- fprintf(debug, "Empty right hand side on line %d in file %s, ignored\n", indexOfLineReadFromFile, fn);
- }
+ // Users are probably using this for lines like
+ // tcoupl = ;v-rescale
+ // comm-grps =
+ // so we accept their intent to use the default behavior.
continue;
}
{
auto message = gmx::formatString("Parameter \"%s\" doubly defined\n",
tokens[0].c_str());
- warning_error(wi, message.c_str());
+ warning_error(wi, message);
}
}
/* This preserves the behaviour of the old code, which issues some
const char *inputMdpFile[] = {
"; File to run my simulation",
"title = simulation",
+ "define = -DBOOLVAR -DVAR=VALUE",
";",
"xtc_grps = System ; was Protein",
"include = -I/home/me/stuff",
"",
"tau-t = 0.1 0.3",
+ "ref-t = ;290 290",
"tinit = 0.3",
"init_step = 0",
"nstcomm = 100",
runTest(inputMdpFile);
}
-// TODO Stop accepting any of these
-TEST_F(GetIrTest, UserErrorsSilentlyTolerated)
+TEST_F(GetIrTest, RejectsNonCommentLineWithNoEquals)
{
- const char *inputMdpFile[] = {
- "title simulation",
- "xtc_grps = ",
- "= -I/home/me/stuff",
- "="
- };
- runTest(joinStrings(inputMdpFile, "\n"));
+ const char *inputMdpFile = "title simulation";
+ EXPECT_DEATH_IF_SUPPORTED(runTest(inputMdpFile), "No '=' to separate");
+}
+
+TEST_F(GetIrTest, AcceptsKeyWithoutValue)
+{
+ // Users are probably using lines like this
+ const char *inputMdpFile = "xtc_grps = ";
+ runTest(inputMdpFile);
+}
+
+TEST_F(GetIrTest, RejectsValueWithoutKey)
+{
+ const char *inputMdpFile = "= -I/home/me/stuff";
+ EXPECT_DEATH_IF_SUPPORTED(runTest(inputMdpFile), "No .mdp parameter name was found");
+}
+
+TEST_F(GetIrTest, RejectsEmptyKeyAndEmptyValue)
+{
+ const char *inputMdpFile = " = ";
+ EXPECT_DEATH_IF_SUPPORTED(runTest(inputMdpFile), "No .mdp parameter name or value was found");
}
-TEST_F(GetIrTest, DefineHandlesAssignmentOnRhs)
+TEST_F(GetIrTest, AcceptsDefineParametersWithValuesIncludingAssignment)
{
const char *inputMdpFile[] = {
"define = -DBOOL -DVAR=VALUE",
runTest(joinStrings(inputMdpFile, "\n"));
}
-TEST_F(GetIrTest, EmptyInputWorks)
+TEST_F(GetIrTest, AcceptsEmptyLines)
{
const char *inputMdpFile = "";
runTest(inputMdpFile);
// These tests observe how the electric-field keys behave, since they
// are currently the only ones using the new Options-style handling.
-TEST_F(GetIrTest, ProducesOutputFromElectricField)
+TEST_F(GetIrTest, AcceptsElectricField)
{
const char *inputMdpFile = "electric-field-x = 1.2 0 0 0";
runTest(inputMdpFile);
}
-TEST_F(GetIrTest, ProducesOutputFromElectricFieldPulsed)
+TEST_F(GetIrTest, AcceptsElectricFieldPulsed)
{
const char *inputMdpFile = "electric-field-y = 3.7 2.0 6.5 1.0";
runTest(inputMdpFile);
}
-TEST_F(GetIrTest, ProducesOutputFromElectricFieldOscillating)
+TEST_F(GetIrTest, AcceptsElectricFieldOscillating)
{
const char *inputMdpFile = "electric-field-z = 3.7 7.5 0 0";
runTest(inputMdpFile);
}
-TEST_F(GetIrTest, TerminatesOnDuplicateOldAndNewKeys)
+TEST_F(GetIrTest, RejectsDuplicateOldAndNewKeys)
{
const char *inputMdpFile[] = {"verlet-buffer-drift = 1.3", "verlet-buffer-tolerance = 2.7"};
EXPECT_DEATH_IF_SUPPORTED(runTest(joinStrings(inputMdpFile, "\n")), "A parameter is present with both");
}
-TEST_F(GetIrTest, ImplicitSolventNoWorks)
+TEST_F(GetIrTest, AcceptsImplicitSolventNo)
{
const char *inputMdpFile = "implicit-solvent = no";
runTest(inputMdpFile);
}
-TEST_F(GetIrTest, ImplicitSolventYesWorks)
+TEST_F(GetIrTest, RejectsImplicitSolventYes)
{
const char *inputMdpFile = "implicit-solvent = yes";
EXPECT_DEATH_IF_SUPPORTED(runTest(inputMdpFile), "Invalid enum");
}
-TEST_F(GetIrTest, HandlesMimic)
+TEST_F(GetIrTest, AcceptsMimic)
{
const char *inputMdpFile[] = {"integrator = mimic", "QMMM-grps = QMatoms"};
runTest(joinStrings(inputMdpFile, "\n"));