-
Notifications
You must be signed in to change notification settings - Fork 9
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
Allow specifying max length when using shortstrings to create short strings #55
base: master
Are you sure you want to change the base?
Conversation
@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!!!" |
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.
I don't think we need these test.
They don't test anything different do they?
We should test things with:
- shortstring below maxlen
- shortstring at maxlen
- shortstring above maxlen
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Including the right-hand side == here seems like it is adding nothing?
It makes it unclear what should throw the error.
@@ -319,7 +319,7 @@ argument `maxlen` is passed. | |||
If the keyword argument `types` is passed with a list (a tuple or Vector) of Unsigned | |||
types, in order of their size, then one of those types will be used. | |||
""" | |||
ShortString(str::Union{String,SubString{String}}, maxlen = sizeof(str); types=def_types) = | |||
ShortString(str::AbstractString, maxlen = sizeof(str); types=def_types) = |
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
Currently
ShortString(ss127"hello",5)
errors, and this fixes that