diff --git a/src/ShortStrings.jl b/src/ShortStrings.jl index 7199f76..505df44 100644 --- a/src/ShortStrings.jl +++ b/src/ShortStrings.jl @@ -2,7 +2,8 @@ __precompile__(true) module ShortStrings using SortingAlgorithms -export ShortString, ShortString15, ShortString7, ShortString3, fsort, fsort! +export ShortString, ShortString15, ShortString7, ShortString3, fsort, fsort!, + @ss15_str, @ss7_str, @ss3_str import Base:unsafe_getindex, == diff --git a/test/runtests.jl b/test/runtests.jl index 543645a..b687707 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,7 +1,6 @@ using ShortStrings using Test, Random -# write your own tests here r = randstring.(1:15) @test all(ShortString15.(r) .== r) a = ShortString15.(r) @@ -21,6 +20,20 @@ a = ShortString{UInt32}.(r) a = ShortString3.(r) @test fsort(a) |> issorted +@test collect(ShortString3("abc")) == ['a', 'b', 'c'] +@test ss15"Short String!!!" === ShortString15("Short String!!!") +@test ss7"ShrtStr" === ShortString7("ShrtStr") +@test ss3"ss3" === ShortString3("ss3") -@test collect(ShortString3("abc")) == ['a', 'b', 'c'] +@test_throws ErrorException ShortString{UInt128}("Short String!!!!") +@test_throws ErrorException ShortString15("Short String!!!!") +@test_throws ErrorException ss15"Short String!!!!" + +@test_throws ErrorException ShortString{UInt64}("ShortStr") +@test_throws ErrorException ShortString7("ShortStr") +@test_throws ErrorException ss7"ShortStr" + +@test_throws ErrorException ShortString{UInt32}("Short") +@test_throws ErrorException ShortString3("Short") +@test_throws ErrorException ss3"Short"