mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
- conversion of positive literals to signed int
- tests
This commit is contained in:
parent
5ef445f64f
commit
c7e6bbb82c
@ -4177,10 +4177,14 @@ BOOST_AUTO_TEST_CASE(positive_integers_to_signed)
|
||||
char const* sourceCode = R"(
|
||||
contract test {
|
||||
int8 public x = 2;
|
||||
int8 public y = 127;
|
||||
int16 public q = 250;
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode, 0, "test");
|
||||
BOOST_CHECK(callContractFunction("x()") == encodeArgs(2));
|
||||
BOOST_CHECK(callContractFunction("y()") == encodeArgs(127));
|
||||
BOOST_CHECK(callContractFunction("q()") == encodeArgs(250));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
@ -1816,6 +1816,46 @@ BOOST_AUTO_TEST_CASE(string_length)
|
||||
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(negative_integers_to_signed_out_of_bound)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract test {
|
||||
int8 public i = -129;
|
||||
}
|
||||
)";
|
||||
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(negative_integers_to_signed_min)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract test {
|
||||
int8 public i = -128;
|
||||
}
|
||||
)";
|
||||
BOOST_CHECK_NO_THROW(parseTextAndResolveNames(sourceCode));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(positive_integers_to_signed_out_of_bound)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract test {
|
||||
int8 public j = 128;
|
||||
}
|
||||
)";
|
||||
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(positive_integers_to_signed_out_of_bound_max)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract test {
|
||||
int8 public j = 127;
|
||||
}
|
||||
)";
|
||||
BOOST_CHECK_NO_THROW(parseTextAndResolveNames(sourceCode));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user