Skip to content

Commit a2ef2a7

Browse files
authored
Merge pull request #47 from JuliaString/ox/generic
Handle constructing from AbstractString
2 parents ce799ae + 48574ed commit a2ef2a7

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

Project.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
name = "ShortStrings"
22
uuid = "63221d1c-8677-4ff0-9126-0ff0817b4975"
3-
authors = ["Dai ZJ <zhuojia.dai@gmail.com>", "ScottPJones <scottjones@alum.mit.edu>",
4-
"Lyndon White <lyndon.white@invenialabs.co.uk>"]
5-
version = "0.3.6"
3+
authors = ["Dai ZJ <zhuojia.dai@gmail.com>", "ScottPJones <scottjones@alum.mit.edu>", "Lyndon White <lyndon.white@invenialabs.co.uk>"]
4+
version = "0.3.7"
65

76
[deps]
87
BitIntegers = "c3b6d118-76ef-56ca-8cc7-ebb389d030a1"
9-
SortingAlgorithms = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
108
MurmurHash3 = "b10b62ed-fbae-5ea5-b934-abaf0477b71d"
9+
SortingAlgorithms = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
1110

1211
[compat]
13-
MurmurHash3 = "1.1"
1412
BitIntegers = "0.2"
13+
MurmurHash3 = "1.1"
1514
SortingAlgorithms = "0.3"
1615
julia = "1"
1716

src/base.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ end
101101
val
102102
end
103103

104+
ShortString{T}(s::AbstractString) where T = ShortString{T}(String(s))
105+
104106
function ShortString{T}(s::Union{String,SubString{String}}) where {T}
105107
sz = sizeof(s)
106108
sz === 0 && return ShortString{T}(T(0))

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ end
133133

134134
@test_throws ErrorException ShortString("foobar", 3)
135135
@test_throws ErrorException ss"foobar"b3
136+
137+
138+
@test ShortString7(Test.GenericString("abcde")) == "abcde"
139+
@test ShortString7(Test.GenericString("abcde")) isa ShortString7
140+
@test ShortString7(SubString(Test.GenericString("abcde"), 2)) == "bcde"
141+
@test ShortString7(SubString(Test.GenericString("abcde"), 2)) isa ShortString7
136142
end
137143

138144

0 commit comments

Comments
 (0)