Skip to content

Commit

Permalink
update shift
Browse files Browse the repository at this point in the history
  • Loading branch information
GiggleLiu committed May 23, 2024
1 parent 0ce4015 commit 9926d84
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/BitStr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ end
@test res == 2
@test typeof(res) == T

@test convert(BitStr{2,LongLongUInt{2, 1}}, convert(T, bit"10")) == lbit"10"
@test convert(BitStr{2,LongLongUInt{1}}, convert(T, bit"10")) == lbit"10"
@test convert(BitStr{2,Int64}, convert(T, bit"10")) === bit"10"
end
end
Expand Down
15 changes: 15 additions & 0 deletions test/longlonguint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,19 @@ using Test, BitBasis
BitBasis.max_num_elements(LongLongUInt{2}, 4) == 40
BitBasis.max_num_elements(UInt, 2) == 64
BitBasis.max_num_elements(Int, 2) == 63
end

@testset "shift" begin
x = LongLongUInt((3, 6))
@test x << 0 == LongLongUInt((3, 6))
@test x << 64 == LongLongUInt((6, 0))
@test x << 65 == LongLongUInt((6<<1, 0))
@test x >> 64 == LongLongUInt((0, 3))
@test x >> 65 == LongLongUInt((0, 1))
@test x << -65 == LongLongUInt((0, 1))
@test x >> -65 == LongLongUInt((6<<1, 0))

x = LongLongUInt((3, 6, 7))
@test x >> 66 == LongLongUInt((UInt(0), UInt(0), UInt(3) << 62 + UInt(1)))
@test x << 63 == LongLongUInt((UInt(1) << 63 + UInt(6) >> 1, UInt(7) >> 1, UInt(1)<<63))
end

0 comments on commit 9926d84

Please sign in to comment.