Skip to content

Commit

Permalink
Add tests for upper bounds of shifts
Browse files Browse the repository at this point in the history
  • Loading branch information
nfurfaro committed Oct 15, 2023
1 parent 917808c commit 98fe352
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/Huffbits.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ contract HuffbitsTest is Test {
assertEq(huffbits.nibbleMask(63), 0x0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
}

function testFailNibbleMask() public {
huffbits.nibbleMask(64);
}

function testByteMask() public {
assertEq(huffbits.byteMask(0), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00);
assertEq(huffbits.byteMask(1), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FF);
Expand All @@ -65,6 +69,10 @@ contract HuffbitsTest is Test {
assertEq(huffbits.byteMask(31), 0x00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
}

function testFailByteMask() public {
huffbits.byteMask(32);
}

function testMultiMask() public {
assertEq(huffbits.multiMask(0), 0);
assertEq(huffbits.multiMask(1), 1);
Expand Down

0 comments on commit 98fe352

Please sign in to comment.