Implemented issue #1656 (Display-->Goto Position dialog should accept + as well as - for number prefixes)

This commit is contained in:
Matthias Koefferlein 2024-03-23 09:07:26 +01:00
parent b4d90ef94c
commit b4d170fa66
3 changed files with 21 additions and 4 deletions

View File

@ -353,9 +353,9 @@ TEST(11)
EXPECT_EQ (x.try_read (tt2), true);
EXPECT_EQ (x.test ("a"), true);
EXPECT_EQ (tt2.to_string (), t2.to_string ());
x = tl::Extractor ("m22.5 *0.55 12.4,-17 ++");
x = tl::Extractor ("m22.5 *0.55 12.4,-17 ##");
EXPECT_EQ (x.try_read (tt2), true);
EXPECT_EQ (x.test ("++"), true);
EXPECT_EQ (x.test ("##"), true);
EXPECT_EQ (tt2.to_string (), "m22.5 *0.55 12.4,-17");
EXPECT_EQ (tt2.to_string (), t3.to_string ());
}

View File

@ -322,10 +322,8 @@ static double local_strtod (const char *cp, const char *&cp_new)
if (*cp == '-') {
s = -1.0;
++cp;
/*
} else if (*cp == '+') {
++cp;
*/
}
// Extract upper digits

View File

@ -305,6 +305,25 @@ TEST(6)
EXPECT_EQ (x3.test (":"), true);
}
TEST(6_double)
{
Extractor x (" 5.5 -2.5 \n+0.125 (no number)");
EXPECT_EQ (x.at_end (), false);
double d = 0.0;
EXPECT_EQ (x.try_read (d), true);
EXPECT_EQ (d, 5.5);
x.read (d);
EXPECT_EQ (d, -2.5);
x.read (d);
EXPECT_EQ (d, 0.125);
x.expect ("(");
}
TEST(7)
{
EXPECT_EQ (tl::to_quoted_string ("a_word!"), "'a_word!'");