-
Notifications
You must be signed in to change notification settings - Fork 9
Allow specifying max length when using shortstrings to create short strings #55
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "ShortStrings" | ||
uuid = "63221d1c-8677-4ff0-9126-0ff0817b4975" | ||
authors = ["Dai ZJ <[email protected]>", "ScottPJones <[email protected]>", "Lyndon White <[email protected]>"] | ||
version = "0.3.11" | ||
version = "0.3.12" | ||
|
||
[deps] | ||
BitIntegers = "c3b6d118-76ef-56ca-8cc7-ebb389d030a1" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,6 +122,34 @@ end | |
@test ShortString7(ShortString7("ab")) isa ShortString7 | ||
|
||
@test_throws ErrorException ShortString3(ShortString7("123456")) | ||
|
||
# Test creating shortstrings with maxlen | ||
@test ShortString( | ||
ss127"Be honest, do you actually need a string longer than this. Seriously. C'mon this is pretty long.", | ||
127, | ||
) == "Be honest, do you actually need a string longer than this. Seriously. C'mon this is pretty long." | ||
@test ShortString( | ||
ss63"Basically a fairly long string really", 63 | ||
) == "Basically a fairly long string really" | ||
@test ShortString(ss31"A Longer String!!!", 31) == "A Longer String!!!" | ||
Comment on lines
+127
to
+134
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need these test. We should test things with:
|
||
@test ShortString(ss15"Short String!!!", 15) == "Short String!!!" | ||
@test ShortString(ss7"ShrtStr", 7) == "ShrtStr" | ||
@test ShortString(ss3"ss3", 3) == "ss3" | ||
@test ShortString("", 0) == "" | ||
|
||
@test_throws ErrorException ShortString( | ||
ss127"Be honest, do you actually need a string longer than this. Seriously. C'mon this is pretty long.", | ||
0, | ||
) == "Be honest, do you actually need a string longer than this. Seriously. C'mon this is pretty long." | ||
@test_throws ErrorException ShortString( | ||
ss63"Basically a fairly long string really", 0 | ||
) == "Basically a fairly long string really" | ||
@test_throws ErrorException ShortString( | ||
ss31"A Longer String!!!", 0 | ||
) == "A Longer String!!!" | ||
@test_throws ErrorException ShortString(ss15"Short String!!!", 0) == "Short String!!!" | ||
@test_throws ErrorException ShortString(ss7"ShrtStr", 0) == "ShrtStr" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Including the right-hand side == here seems like it is adding nothing? |
||
# @test_throws ErrorException ShortString(ss3"ss3", 0) == "ss3" Why doesn't this throw an error? | ||
end | ||
|
||
@testset "promote rule" begin | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If relaxing it always to
AbstractString
,need to also test that
Test.GenericString
works