forked from Uniswap/v3-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLowGasSafeMathEchidnaTest.sol
36 lines (30 loc) · 1.02 KB
/
LowGasSafeMathEchidnaTest.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
import '../libraries/LowGasSafeMath.sol';
contract LowGasSafeMathEchidnaTest {
function checkAdd(uint256 x, uint256 y) external pure {
uint256 z = LowGasSafeMath.add(x, y);
assert(z == x + y);
assert(z >= x && z >= y);
}
function checkSub(uint256 x, uint256 y) external pure {
uint256 z = LowGasSafeMath.sub(x, y);
assert(z == x - y);
assert(z <= x);
}
function checkMul(uint256 x, uint256 y) external pure {
uint256 z = LowGasSafeMath.mul(x, y);
assert(z == x * y);
assert(x == 0 || y == 0 || (z >= x && z >= y));
}
function checkAddi(int256 x, int256 y) external pure {
int256 z = LowGasSafeMath.add(x, y);
assert(z == x + y);
assert(y < 0 ? z < x : z >= x);
}
function checkSubi(int256 x, int256 y) external pure {
int256 z = LowGasSafeMath.sub(x, y);
assert(z == x - y);
assert(y < 0 ? z > x : z <= x);
}
}