Skip to content

Commit

Permalink
Merge pull request #5 from kmsquire/feature/export-test-macros
Browse files Browse the repository at this point in the history
Export and test string macros
  • Loading branch information
xiaodaigh authored Feb 12, 2020
2 parents 93eb4e4 + c0c4722 commit 6ca9a4f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/ShortStrings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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, ==

Expand Down
17 changes: 15 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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"

0 comments on commit 6ca9a4f

Please sign in to comment.