aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-08-07 17:52:01 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-08-07 20:44:24 +0800
commit5298d818c4808377d3acb8980c2e763b9f86ada7 (patch)
tree08400077cae5819528a0d80555d0a8891daf1d54 /test/libsolidity/SolidityEndToEndTest.cpp
parentb0f9fc5af08a34f3025acf37db170ddca77796e1 (diff)
downloaddexon-solidity-5298d818c4808377d3acb8980c2e763b9f86ada7.tar.gz
dexon-solidity-5298d818c4808377d3acb8980c2e763b9f86ada7.tar.zst
dexon-solidity-5298d818c4808377d3acb8980c2e763b9f86ada7.zip
Add test for abi.encode (negative) literals
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 9c287e5e..bd1d9de7 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -12527,6 +12527,42 @@ BOOST_AUTO_TEST_CASE(abi_encode_empty_string_v2)
0x00
));
}
+
+BOOST_AUTO_TEST_CASE(abi_encode_rational)
+{
+ char const* sourceCode = R"(
+ // Tests that rational numbers (even negative ones) are encoded properly.
+ contract C {
+ function f() public pure returns (bytes memory) {
+ return abi.encode(1, -2);
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(
+ 0x20,
+ 0x40, u256(1), u256(-2)
+ ));
+}
+
+BOOST_AUTO_TEST_CASE(abi_encode_rational_v2)
+{
+ char const* sourceCode = R"(
+ // Tests that rational numbers (even negative ones) are encoded properly.
+ pragma experimental ABIEncoderV2;
+ contract C {
+ function f() public pure returns (bytes memory) {
+ return abi.encode(1, -2);
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(
+ 0x20,
+ 0x40, u256(1), u256(-2)
+ ));
+}
+
BOOST_AUTO_TEST_CASE(abi_encode_call)
{
char const* sourceCode = R"T(