forked from foundry-rs/foundry
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFuzzUint.t.sol
More file actions
45 lines (34 loc) · 1.01 KB
/
FuzzUint.t.sol
File metadata and controls
45 lines (34 loc) · 1.01 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
// 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(uint256) public {
assertTrue(true);
}
function testNegativeHalf(uint256 val) public {
assertTrue(val < 2 ** 128 - 1);
}
function testNegative0(uint256 val) public {
assertTrue(val != 0);
}
function testNegative2(uint256 val) public {
assertTrue(val != 2);
}
function testNegative2Max(uint256 val) public {
assertTrue(val != type(uint256).max - 2);
}
function testNegativeMax(uint256 val) public {
assertTrue(val != type(uint256).max);
}
function testEquality(uint256 x, uint256 y) public {
uint256 xy;
unchecked {
xy = x * y;
}
if ((x != 0 && xy / x != y)) {
return;
}
assertEq(((xy - 1) / 1e18) + 1, (xy - 1) / (1e18 + 1));
}
}