Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional test cases to improve coverage #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ShortStrings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module ShortStrings
using BitIntegers
using SortingAlgorithms

export fsort, fsort!, ShortString, ShortString3, ShortString7, ShortString15
export fsort, fsort!, fsortperm, ShortString, ShortString3, ShortString7, ShortString15
export ShortString31, ShortString63, ShortString127, ShortString255
export @ss_str, @ss3_str, @ss7_str, @ss15_str, @ss31_str, @ss63_str, @ss127_str, @ss255_str

Expand Down
15 changes: 15 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ function basic_test(string_type, constructor, max_len)

a = constructor.(r)
@test fsort(a) |> issorted
@test issorted(fsort!(a))
@test issorted(fsortperm(a)) # sortperm is sorted because we sorted a in-place

@test collect(constructor("z"^max_len)) == fill('z', max_len)
@test_throws ErrorException constructor("a"^(max_len+1))
Expand Down Expand Up @@ -172,3 +174,16 @@ end
@test split(ShortString15("abc XYZ x")) == ["abc", "XYZ", "x"]
@test split(ShortString15("abc XYZ x")) isa Vector{SubString{ShortString15}}
end

@testset "extra coverage" begin
@test codeunit(ShortString("a🍕c")) == UInt8
@test convert(ShortString{UInt32}, "abc") === ss3"abc"
@test convert(String, ss3"abc") === "abc"
@test length(ShortString("¢")) == 2 # 2-byte character
@test ShortStrings.cmp(ss3"abc", ss7"abc") == 0
@test promote_rule(String, ShortString7) == String
@test promote_rule(ShortString3, ShortString7) == ShortString7
@test promote_rule(ShortString7, ShortString3) == ShortString7
@test_throws ArgumentError ss"abc"3000
@test_throws LoadError @macroexpand ss"abc"true
end