diff --git a/test/LibBit.t.sol b/test/LibBit.t.sol index d2ea65e607..7039680307 100644 --- a/test/LibBit.t.sol +++ b/test/LibBit.t.sol @@ -296,10 +296,18 @@ contract LibBitTest is SoladyTest { } } + function testCountZeroBytesDifferential(bytes32) public { + testCountZeroBytesDifferential(_randomSmallBytes()); + } + function testCountZeroBytesDifferential(bytes memory s) public { assertEq(LibBit.countZeroBytes(s), _countZeroBytesOriginal(s)); } + function testCountZeroBytesCalldataDifferential(bytes32) public { + this.testCountZeroBytesCalldataDifferential(_randomSmallBytes()); + } + function testCountZeroBytesCalldataDifferential(bytes calldata s) public { assertEq(LibBit.countZeroBytesCalldata(s), _countZeroBytesOriginal(s)); } @@ -312,4 +320,19 @@ contract LibBitTest is SoladyTest { return c; } } + + function _randomSmallBytes() internal returns (bytes memory) { + uint256 n = _bound(_random(), 0, 100); + uint256 r = _randomUniform(); + uint256 x = r >> 248; + bytes memory s = new bytes(n); + /// @solidity memory-safe-assembly + assembly { + mstore(0x00, r) + for { let i := 0 } lt(i, n) { i := add(i, 1) } { + if and(1, shr(i, r)) { mstore8(add(add(s, 0x20), i), x) } + } + } + return s; + } } diff --git a/test/SemVerLib.t.sol b/test/SemVerLib.t.sol index 4a81bcf7f5..42d9ddd211 100644 --- a/test/SemVerLib.t.sol +++ b/test/SemVerLib.t.sol @@ -264,5 +264,8 @@ contract SemVerLibTest is SoladyTest { _checkEq("01.002.0003", "1.2.3"); _checkEq("v01.2.03", "1.2.3"); + + _checkLt("", "1.0.0"); + _checkEq("", "0.0.0"); } }