forked from foundry-rs/foundry
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFuzzInt.t.sol
More file actions
57 lines (43 loc) · 1.29 KB
/
FuzzInt.t.sol
File metadata and controls
57 lines (43 loc) · 1.29 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.18;
import "ds-test/test.sol";
// See https://github.com/foundry-rs/foundry/pull/735 for context
contract FuzzNumbersTest is DSTest {
function testPositive(int256) public {
assertTrue(true);
}
function testNegativeHalf(int256 val) public {
assertTrue(val < 2 ** 128 - 1);
}
function testNegative0(int256 val) public {
assertTrue(val != 0);
}
function testNegative1(int256 val) public {
assertTrue(val != -1);
}
function testNegative2(int128 val) public {
assertTrue(val != 1);
}
function testNegativeMax0(int256 val) public {
assertTrue(val != type(int256).max);
}
function testNegativeMax1(int256 val) public {
assertTrue(val != type(int256).max - 2);
}
function testNegativeMin0(int256 val) public {
assertTrue(val != type(int256).min);
}
function testNegativeMin1(int256 val) public {
assertTrue(val != type(int256).min + 2);
}
function testEquality(int256 x, int256 y) public {
int256 xy;
unchecked {
xy = x * y;
}
if ((x != 0 && xy / x != y)) {
return;
}
assertEq(((xy - 1) / 1e18) + 1, (xy - 1) / (1e18 + 1));
}
}