Feature/uint enumerable set tests #2253 (#2254)

* feature: setting sublevel test scenario for AddressSet

* feat: adding tests for EnumerableSet.UintSet

* feat: adding Behavior and AddressSet and UintSet tests
This commit is contained in:
Julian M. Rodriguez
2020-06-04 14:57:35 -03:00
committed by GitHub
parent a81e948fc9
commit d7a6e7be2e
3 changed files with 171 additions and 108 deletions

View File

@ -4,7 +4,8 @@ pragma solidity ^0.6.0;
import "../utils/EnumerableSet.sol";
contract EnumerableSetMock {
// AddressSet
contract EnumerableAddressSetMock {
using EnumerableSet for EnumerableSet.AddressSet;
event OperationResult(bool result);
@ -33,3 +34,34 @@ contract EnumerableSetMock {
return _set.at(index);
}
}
// UintSet
contract EnumerableUintSetMock {
using EnumerableSet for EnumerableSet.UintSet;
event OperationResult(bool result);
EnumerableSet.UintSet private _set;
function contains(uint256 value) public view returns (bool) {
return _set.contains(value);
}
function add(uint256 value) public {
bool result = _set.add(value);
emit OperationResult(result);
}
function remove(uint256 value) public {
bool result = _set.remove(value);
emit OperationResult(result);
}
function length() public view returns (uint256) {
return _set.length();
}
function at(uint256 index) public view returns (uint256) {
return _set.at(index);
}
}