diff options
Diffstat (limited to 'unittests/ASTMatchers/Dynamic/ParserTest.cpp')
-rw-r--r-- | unittests/ASTMatchers/Dynamic/ParserTest.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/unittests/ASTMatchers/Dynamic/ParserTest.cpp b/unittests/ASTMatchers/Dynamic/ParserTest.cpp index 504724362a..ed184a8c14 100644 --- a/unittests/ASTMatchers/Dynamic/ParserTest.cpp +++ b/unittests/ASTMatchers/Dynamic/ParserTest.cpp @@ -84,6 +84,21 @@ TEST(ParserTest, ParseBoolean) { EXPECT_EQ(false, Sema.Values[1].getBoolean()); } +TEST(ParserTest, ParseDouble) { + MockSema Sema; + Sema.parse("1.0"); + Sema.parse("2.0f"); + Sema.parse("34.56e-78"); + Sema.parse("4.E+6"); + Sema.parse("1"); + EXPECT_EQ(5U, Sema.Values.size()); + EXPECT_EQ(1.0, Sema.Values[0].getDouble()); + EXPECT_EQ("1:1: Error parsing numeric literal: <2.0f>", Sema.Errors[1]); + EXPECT_EQ(34.56e-78, Sema.Values[2].getDouble()); + EXPECT_EQ(4e+6, Sema.Values[3].getDouble()); + EXPECT_FALSE(Sema.Values[4].isDouble()); +} + TEST(ParserTest, ParseUnsigned) { MockSema Sema; Sema.parse("0"); @@ -95,8 +110,8 @@ TEST(ParserTest, ParseUnsigned) { EXPECT_EQ(0U, Sema.Values[0].getUnsigned()); EXPECT_EQ(123U, Sema.Values[1].getUnsigned()); EXPECT_EQ(31U, Sema.Values[2].getUnsigned()); - EXPECT_EQ("1:1: Error parsing unsigned token: <12345678901>", Sema.Errors[3]); - EXPECT_EQ("1:1: Error parsing unsigned token: <1a1>", Sema.Errors[4]); + EXPECT_EQ("1:1: Error parsing numeric literal: <12345678901>", Sema.Errors[3]); + EXPECT_EQ("1:1: Error parsing numeric literal: <1a1>", Sema.Errors[4]); } TEST(ParserTest, ParseString) { |