make format style variable tests unambiguous for rounding issues

This commit is contained in:
Axel Kohlmeyer
2024-12-17 21:48:34 -05:00
parent aadc87279d
commit f06c4daee0

View File

@ -731,8 +731,8 @@ TEST_F(VariableTest, LabelMapMolecular)
TEST_F(VariableTest, Format)
{
BEGIN_HIDE_OUTPUT();
command("variable idx index -0.625");
command("variable one equal -0.625");
command("variable idx index -0.622");
command("variable one equal -0.622");
command("variable two equal 1.0e-20");
command("variable three equal 1.0e10");
command("variable f1one format one \"%8.4f\"");
@ -754,25 +754,25 @@ TEST_F(VariableTest, Format)
command("variable g3one format one \"%5g\"");
command("variable g3two format two \"%g\"");
END_HIDE_OUTPUT();
EXPECT_THAT(variable->retrieve("one"), StrEq("-0.625"));
EXPECT_THAT(variable->retrieve("one"), StrEq("-0.622"));
EXPECT_THAT(variable->retrieve("two"), StrEq("1e-20"));
EXPECT_THAT(variable->retrieve("f1one"), StrEq(" -0.6250"));
EXPECT_THAT(variable->retrieve("f1one"), StrEq(" -0.6220"));
EXPECT_THAT(variable->retrieve("f1two"), StrEq(" 0.0000"));
EXPECT_THAT(variable->retrieve("f2one"), StrEq("-0.62"));
EXPECT_THAT(variable->retrieve("f2two"), StrEq(" 0.0000000000000000000100000"));
EXPECT_THAT(variable->retrieve("f3one"), StrEq("-0.625000"));
EXPECT_THAT(variable->retrieve("f3one"), StrEq("-0.622000"));
EXPECT_THAT(variable->retrieve("f3two"), StrEq("0.000000"));
EXPECT_THAT(variable->retrieve("e1one"), StrEq(" -6.2500e-01"));
EXPECT_THAT(variable->retrieve("e1one"), StrEq(" -6.2200e-01"));
EXPECT_THAT(variable->retrieve("e1two"), StrEq("1.0000e-20 "));
EXPECT_THAT(variable->retrieve("e2one"), StrEq("-6.25E-01"));
EXPECT_THAT(variable->retrieve("e2one"), StrEq("-6.22E-01"));
EXPECT_THAT(variable->retrieve("e2two"), StrEq(" 9.999999999999999E-21"));
EXPECT_THAT(variable->retrieve("e3one"), StrEq("-6.250000e-01"));
EXPECT_THAT(variable->retrieve("e3one"), StrEq("-6.220000e-01"));
EXPECT_THAT(variable->retrieve("e3two"), StrEq("1.000000e-20"));
EXPECT_THAT(variable->retrieve("g1one"), StrEq(" -0.625"));
EXPECT_THAT(variable->retrieve("g1one"), StrEq(" -0.622"));
EXPECT_THAT(variable->retrieve("g1two"), StrEq("1e-20 "));
EXPECT_THAT(variable->retrieve("g2one"), StrEq("-0.62"));
EXPECT_THAT(variable->retrieve("g2two"), StrEq(" 1E-20"));
EXPECT_THAT(variable->retrieve("g3one"), StrEq("-0.625"));
EXPECT_THAT(variable->retrieve("g3one"), StrEq("-0.622"));
EXPECT_THAT(variable->retrieve("g3two"), StrEq("1e-20"));
BEGIN_HIDE_OUTPUT();
@ -782,7 +782,7 @@ TEST_F(VariableTest, Format)
command("variable f1three format three %g");
command("variable three delete");
END_HIDE_OUTPUT();
EXPECT_THAT(variable->retrieve("f1one"), StrEq("-0.6250 "));
EXPECT_THAT(variable->retrieve("f1one"), StrEq("-0.6220 "));
TEST_FAILURE(".*ERROR: Variable f1idx: format variable idx has incompatible style.*",
command("variable f1idx format idx %8.4f"););