Commit a786fa02 authored by Kazunori Fujiwara's avatar Kazunori Fujiwara
Browse files

[2992] Added integer conversion tests (LONG_MAX, -LONG_MAX, LONG_MIN)

       Added floating underflow test
parent 25fec05f
......@@ -146,6 +146,22 @@ TEST(Element, from_and_to_json) {
EXPECT_EQ("100", Element::fromJSON("1e2")->str());
EXPECT_EQ("100", Element::fromJSON("+1e2")->str());
EXPECT_EQ("-100", Element::fromJSON("-1e2")->str());
// LONG_MAX, -LONG_MAX, LONG_MIN test
std::ostringstream longmax, minus_longmax, longmin;
longmax << LONG_MAX;
minus_longmax << -LONG_MAX;
longmin << LONG_MIN;
EXPECT_NO_THROW( {
EXPECT_EQ(longmax.str(), Element::fromJSON(longmax.str())->str());
});
EXPECT_NO_THROW( {
EXPECT_EQ(minus_longmax.str(), Element::fromJSON(minus_longmax.str())->str());
});
EXPECT_NO_THROW( {
EXPECT_EQ(longmin.str(), Element::fromJSON(longmin.str())->str());
});
EXPECT_EQ("0.01", Element::fromJSON("1e-2")->str());
EXPECT_EQ("0.01", Element::fromJSON(".01")->str());
EXPECT_EQ("-0.01", Element::fromJSON("-1e-2")->str());
......@@ -173,6 +189,8 @@ TEST(Element, from_and_to_json) {
EXPECT_THROW(Element::fromJSON("-1.1e12345678901234567890")->str(), JSONError);
EXPECT_THROW(Element::fromJSON("1e12345678901234567890")->str(), JSONError);
EXPECT_THROW(Element::fromJSON("1e50000")->str(), JSONError);
// number underflow
EXPECT_THROW(Element::fromJSON("1.1e-12345678901234567890")->str(), JSONError);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment