Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobnissen committed Oct 26, 2024
1 parent d562b87 commit 81bb0b8
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/longsequences/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ function _findlast(seq::SeqOrView{<:KNOWN_ALPHABETS}, enc::UInt64)
while body_i - unroll + 2 > body_stop
u = zero(UInt64)
for j in 0:unroll - 1
u |= set_zero_encoding(BitsPerSymbol(seq), @inbounds(data[body_i + j]) enc)
u |= set_zero_encoding(BitsPerSymbol(seq), @inbounds(data[body_i - j]) enc)
end
iszero(u) || break
i -= symbols_per_data_element(seq) * unroll
Expand Down
11 changes: 11 additions & 0 deletions test/longsequences/basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,13 @@ end
ACGTN
"""
@test a == b

a = randdnaseq(512)
a[111] = DNA_G
b = copy(a)
@test a == b
a[111] = DNA_C
@test a != b
end

@testset "RNA" begin
Expand Down Expand Up @@ -373,6 +380,10 @@ end
X
"""
@test a == b

a = randaaseq(131)
b = copy(a)
@test a == b
end
end

Expand Down
10 changes: 10 additions & 0 deletions test/longsequences/find.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@
@test findnext(==(DNA_M), seq, 8) == 8
@test findnext(==(DNA_M), seq, 9) == 21

# Very large sequence so it hits the inner SIMD loop
seq = randdnaseq(541)
seq[100] = DNA_Gap
@test findfirst(==(DNA_Gap), seq) == findfirst(isgap, seq) == 100
seq[100] = DNA_A
seq[500] = DNA_Gap
@test findlast(==(DNA_Gap), seq) == findlast(isgap, seq) == 500
seq[500] = DNA_A
@test findfirst(==(DNA_Gap), seq) == findlast(isgap, seq) == nothing

# View with only tail
# 1234
seq = view(aa"KWYPAV-L", 3:6)
Expand Down
14 changes: 14 additions & 0 deletions test/longsequences/seqview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ end
@test String(seq) == "ANKYH"
end

@testset "Equality" begin
for size in [41, 504, 7]
for offset in [0, 3, 32]
seq = randrnaseq(size)
seq2 = view(randrnaseq(offset) * seq * randrnaseq(15), offset+1:offset+size)
@test seq == seq2
seq[4] = RNA_Gap
@test seq != seq2
seq3 = view(seq, 1:size)
@test seq == seq3
end
end
end

# Added after issue 260
@testset "Random construction" begin
for i in 1:100
Expand Down

0 comments on commit 81bb0b8

Please sign in to comment.