Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Commit

Permalink
Add failure cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Aiee committed Aug 20, 2021
1 parent 8f7bffe commit 7ec7ae1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/common/datatypes/test/ValueTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,13 +780,30 @@ TEST(Value, TypeCast) {
EXPECT_EQ(Value::Type::INT, vi.type());
EXPECT_EQ(1000, vi.getInt());

vi = Value("1.0e3").toInt();
EXPECT_EQ(Value::Type::INT, vi.type());
EXPECT_EQ(1000, vi.getInt());

vi = Value("5E4").toInt();
EXPECT_EQ(Value::Type::INT, vi.type());
EXPECT_EQ(50000, vi.getInt());

vi = Value("1.5E3").toInt();
EXPECT_EQ(Value::Type::INT, vi.type());
EXPECT_EQ(1500, vi.getInt());

// fail to parse
vi = Value("1.5.2E3").toInt();
EXPECT_EQ(Value::kNullValue, vi);

vi = Value("eeeEE").toInt();
EXPECT_EQ(Value::kNullValue, vi);

vi = Value("1e").toInt();
EXPECT_EQ(Value::kNullValue, vi);

vi = Value("E3").toInt();
EXPECT_EQ(Value::kNullValue, vi);
}
}

Expand Down

0 comments on commit 7ec7ae1

Please sign in to comment.