* Add Arrays library with unit tests (#1209)
* prepared due to snapshot token requirements
* add library with method to find upper bound
* add unit test for basic and edge cases
* Imporove documentation for Arrays library
Simplify Arrays.test.js to use short arrays as test date
* Added comment for uint256 mid variable.
* Explaned why uint256 mid variable calculated as Math.average is safe to use as index of array.
(cherry picked from commit f7e53d90fa)
This commit is contained in:
committed by
Nicolás Venturo
parent
66bad4ff2a
commit
8d6250cd5a
18
contracts/mocks/ArraysImpl.sol
Normal file
18
contracts/mocks/ArraysImpl.sol
Normal file
@ -0,0 +1,18 @@
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../utils/Arrays.sol";
|
||||
|
||||
contract ArraysImpl {
|
||||
|
||||
using Arrays for uint256[];
|
||||
|
||||
uint256[] private array;
|
||||
|
||||
constructor(uint256[] _array) public {
|
||||
array = _array;
|
||||
}
|
||||
|
||||
function findUpperBound(uint256 _element) external view returns (uint256) {
|
||||
return array.findUpperBound(_element);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user