Skip to content

Commit 8bab51b

Browse files
authored
Merge branch 'master' into spj/updateci
2 parents 6923055 + 077b721 commit 8bab51b

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/legacy.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
# Renamed from ascii to to_ascii, to prevent issues with Base.ascii
66
to_ascii(str) = convert(ASCIIStr, str)
7-
to_ascii(pnt::Ptr{UInt8}) = convert(ASCIIStr, unsafe_string(p))
8-
to_ascii(pnt::Ptr{UInt8}, len::Integer) = convert(ASCIIStr, unsafe_string(p, len))
7+
to_ascii(p::Ptr{UInt8}) = convert(ASCIIStr, unsafe_string(p))
8+
to_ascii(p::Ptr{UInt8}, len::Integer) = convert(ASCIIStr, unsafe_string(p, len))
99

1010
"""
1111
utf8(s)

test/basic.jl

+13
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ end
1616

1717
string_types = keys(compat_types)
1818

19+
legacy_types = Dict(ASCIIStr => to_ascii,
20+
UTF8Str => utf8,
21+
UTF16Str => utf16,
22+
UTF32Str => utf32)
23+
1924
## create type specific test strings
2025
test_strings_base = Dict()
2126
for T in AllCharTypes
@@ -28,6 +33,14 @@ end
2833
end
2934
end
3035

36+
@testset "legacy constructors" begin
37+
for (ST, constructor) in legacy_types, str in test_strings_base[ASCIIChr]
38+
vec = Vector{codeunit(ST)}(codeunits(str))
39+
@eval @test $constructor($vec) == $str
40+
@eval @test $constructor(pointer($vec), $(length(vec))) == $str
41+
end
42+
end
43+
3144
@testset "empty strings" begin
3245
for ST in keys(compat_types)
3346
@eval @test is_empty(convert($ST, ""))

0 commit comments

Comments
 (0)