Skip to content

Commit

Permalink
improved clog2() test
Browse files Browse the repository at this point in the history
  • Loading branch information
desmonddak committed Sep 15, 2023
1 parent e362559 commit 2d3f98e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/big_logic_value_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ void main() {
expect(negbfive % two, LogicValue.ofBigInt(BigInt.from(1), len));
});
test('clog test len=$len', () {
final negnum = LogicValue.ofInt(-1, len);
expect(negnum.clog2(), LogicValue.ofInt(len, len));
for (final l in [1, 2, 3]) {
expect((negnum >>> l).clog2(), LogicValue.ofInt(len - l, len));
}
for (final l in [len - 5, len - 4, len - 3, len - 2]) {
final bignum = LogicValue.ofBigInt(BigInt.from(1) << l, len);
expect(bignum.clog2(), LogicValue.ofInt(l, len));
Expand Down

0 comments on commit 2d3f98e

Please sign in to comment.