mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Add test for abi.encode (negative) literals
This commit is contained in:
		
							parent
							
								
									b0f9fc5af0
								
							
						
					
					
						commit
						5298d818c4
					
				| @ -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( | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user