The home for Hyperlane core contracts, sdk packages, and other infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
hyperlane-monorepo/solidity/test/lib/LibBit.t.sol

34 lines
864 B

// SPDX-License-Identifier: MIT or Apache-2.0
pragma solidity ^0.8.13;
import {Test} from "forge-std/Test.sol";
import {LibBit} from "../../contracts/libs/LibBit.sol";
contract LibBitTest is Test {
using LibBit for uint256;
uint256 testValue;
uint256 MAX_INT =
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
function setUp() public {
testValue = 0;
}
function testSetBit(uint8 index) public {
testValue = testValue.setBit(index);
assertEq(testValue, 2**index);
}
function testClearBit(uint8 index) public {
testValue = MAX_INT;
testValue = testValue.clearBit(index);
assertEq(testValue + 2**index, MAX_INT);
}
function testIsBitSet(uint8 index) public {
testValue = 2**index;
assertTrue(testValue.isBitSet(index));
}
}