|
| 1 | +// SPDX-License-Identifier: MIT |
| 2 | +pragma solidity ^0.8.30; |
| 3 | + |
| 4 | +import {Test} from "forge-std/Test.sol"; |
| 5 | +import {Protocol} from "src/types/Enums.sol"; |
| 6 | +import {Stream, createStream} from "src/types/Stream.sol"; |
| 7 | + |
| 8 | +contract StreamTest is Test { |
| 9 | + function test_fuzz_parseProtocol(uint8 x) public pure { |
| 10 | + vm.assume(x <= uint8(type(Protocol).max)); |
| 11 | + Stream s = createStream(abi.encodePacked(Protocol(x))); |
| 12 | + assertEq(uint8(s.parseProtocol()), x); |
| 13 | + } |
| 14 | + |
| 15 | + function test_fuzz_parseAddress(address x) public pure { |
| 16 | + Stream s = createStream(abi.encodePacked(x)); |
| 17 | + assertEq(s.parseAddress(), x); |
| 18 | + } |
| 19 | + |
| 20 | + function test_fuzz_parseUint8(uint8 x) public pure { |
| 21 | + Stream s = createStream(abi.encodePacked(x)); |
| 22 | + assertEq(s.parseUint8(), x); |
| 23 | + } |
| 24 | + |
| 25 | + function test_fuzz_parseUint16(uint16 x) public pure { |
| 26 | + Stream s = createStream(abi.encodePacked(x)); |
| 27 | + assertEq(s.parseUint16(), x); |
| 28 | + } |
| 29 | + |
| 30 | + function test_fuzz_parseUint24(uint24 x) public pure { |
| 31 | + Stream s = createStream(abi.encodePacked(x)); |
| 32 | + assertEq(s.parseUint24(), x); |
| 33 | + } |
| 34 | + |
| 35 | + function test_fuzz_parseUint48(uint48 x) public pure { |
| 36 | + Stream s = createStream(abi.encodePacked(x)); |
| 37 | + assertEq(s.parseUint48(), x); |
| 38 | + } |
| 39 | + |
| 40 | + function test_fuzz_parseUint128(uint128 x) public pure { |
| 41 | + Stream s = createStream(abi.encodePacked(x)); |
| 42 | + assertEq(s.parseUint128(), x); |
| 43 | + } |
| 44 | + |
| 45 | + function test_fuzz_parseUint160(uint160 x) public pure { |
| 46 | + Stream s = createStream(abi.encodePacked(x)); |
| 47 | + assertEq(s.parseUint160(), x); |
| 48 | + } |
| 49 | + |
| 50 | + function test_fuzz_parseUint256(uint256 x) public pure { |
| 51 | + Stream s = createStream(abi.encodePacked(x)); |
| 52 | + assertEq(s.parseUint256(), x); |
| 53 | + } |
| 54 | + |
| 55 | + function test_fuzz_parseInt256(int256 x) public pure { |
| 56 | + Stream s = createStream(abi.encodePacked(x)); |
| 57 | + assertEq(s.parseInt256(), x); |
| 58 | + } |
| 59 | + |
| 60 | + function test_fuzz_parseBytes4(bytes4 x) public pure { |
| 61 | + Stream s = createStream(abi.encodePacked(x)); |
| 62 | + assertEq(s.parseBytes4(), x); |
| 63 | + } |
| 64 | + |
| 65 | + function test_fuzz_parseBytes32(bytes32 x) public pure { |
| 66 | + Stream s = createStream(abi.encodePacked(x)); |
| 67 | + assertEq(s.parseBytes32(), x); |
| 68 | + } |
| 69 | + |
| 70 | + function test_fuzz_parseBytes(bytes memory x) public pure { |
| 71 | + Stream s = createStream(abi.encodePacked(x.length, x)); |
| 72 | + assertEq(s.parseBytes(), x); |
| 73 | + } |
| 74 | +} |
0 commit comments