@@ -7,27 +7,27 @@ import "cheats/Vm.sol";
7
7
contract RandomUint is DSTest {
8
8
Vm constant vm = Vm (HEVM_ADDRESS);
9
9
10
- // All tests use `>=` and `<=` to verify that ranges are inclusive and that
11
- // a value of zero may be generated.
12
10
function testRandomUint () public {
13
- uint256 rand = vm.randomUint ();
14
- assertTrue (rand >= 0 );
11
+ vm.randomUint ();
15
12
}
16
13
17
- function testRandomUint (uint256 min , uint256 max ) public {
18
- vm.assume (max >= min);
19
- uint256 rand = vm.randomUint (min, max);
20
- assertTrue (rand >= min, "rand >= min " );
21
- assertTrue (rand <= max, "rand <= max " );
14
+ function testRandomUintRangeOverflow () public {
15
+ vm.randomUint (0 , uint256 (int256 (- 1 )));
22
16
}
23
17
24
- function testRandomUint (uint256 val ) public {
18
+ function testRandomUintSame (uint256 val ) public {
25
19
uint256 rand = vm.randomUint (val, val);
26
20
assertTrue (rand == val);
27
21
}
28
22
23
+ function testRandomUintRange (uint256 min , uint256 max ) public {
24
+ vm.assume (max >= min);
25
+ uint256 rand = vm.randomUint (min, max);
26
+ assertTrue (rand >= min, "rand >= min " );
27
+ assertTrue (rand <= max, "rand <= max " );
28
+ }
29
+
29
30
function testRandomAddress () public {
30
- address rand = vm.randomAddress ();
31
- assertTrue (rand >= address (0 ));
31
+ vm.randomAddress ();
32
32
}
33
33
}
0 commit comments