watcher-ts/packages/solidity-mapper/test/contracts/TestIntegers.sol
Ashwin Phatak b243025ca8
Test cases in solidity-mapper for contract, fixed-size byte arrays and enum types (#26)
* Add tests for getStorageInfo and getEventNameTopics.

* Lint solidity-mapper package code.

* Add test for contract type.

* Add test for fixed size byte arrays.

* Add test for Enum types.

* Add tests for variables packed together and using single slot.

* Fix comments in test contracts.

Co-authored-by: nikugogoi <95nikass@gmail.com>
2021-06-02 11:23:33 +05:30

35 lines
876 B
Solidity

// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
contract TestIntegers {
// Following integer type variables are packed together in a single slot since the combined size is less than 32 bytes.
int8 int1;
int16 int2;
// Integer type variable is stored in the next slot as it needs 32 bytes of storage.
int256 int3;
// Integer type variable is stored in the next slot as there is not enough space for it in the previous slot.
int32 int4;
// Set variable int1.
function setInt1(int8 value) external {
int1 = value;
}
// Set variable int2.
function setInt2(int16 value) external {
int2 = value;
}
// Set variable int3.
function setInt3(int256 value) external {
int3 = value;
}
// Set variable int4.
function setInt4(int32 value) external {
int4 = value;
}
}