Skip to content
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

More testsets, fix commented out test, add Array{UInt8} conversion test #56586

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions test/strings/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,7 @@ end
@test_throws StringIndexError get(utf8_str, 2, 'X')
end

#=
# issue #7764
let
@testset "issue #7764" begin
srep = repeat("Σβ",2)
s="Σβ"
ss=SubString(s,1,lastindex(s))
Expand All @@ -358,16 +356,15 @@ let
@test iterate(srep, 7) == ('β',9)

@test srep[7] == 'β'
@test_throws BoundsError srep[8]
@test_throws StringIndexError srep[8]
end
=#

# This caused JuliaLang/JSON.jl#82
@test first('\x00':'\x7f') === '\x00'
@test last('\x00':'\x7f') === '\x7f'

# make sure substrings do not accept code unit if it is not start of codepoint
let s = "x\u0302"
@testset "make sure substrings do not accept code unit if it is not start of codepoint" begin
s = "x\u0302"
@test s[1:2] == s
@test_throws BoundsError s[0:3]
@test_throws BoundsError s[1:4]
Expand Down Expand Up @@ -1076,8 +1073,8 @@ let s = "∀x∃y", u = codeunits(s)
@test Base.elsize(u) == Base.elsize(typeof(u)) == 1
end

# issue #24388
let v = unsafe_wrap(Vector{UInt8}, "abc")
@testset "issue #24388" begin
v = unsafe_wrap(Vector{UInt8}, "abc")
s = String(v)
@test_throws BoundsError v[1]
push!(v, UInt8('x'))
Expand All @@ -1093,8 +1090,8 @@ let v = [0x40,0x41,0x42]
@test String(view(v, 2:3)) == "AB"
end

# issue #54369
let v = Base.StringMemory(3)
@testset "issue #54369" begin
v = Base.StringMemory(3)
v .= [0x41,0x42,0x43]
s = String(v)
@test s == "ABC"
Expand All @@ -1116,8 +1113,8 @@ let rng = MersenneTwister(1), strs = ["∀εa∀aε"*String(rand(rng, UInt8, 100
end
end

# conversion of SubString to the same type, issue #25525
let x = SubString("ab", 1, 1)
@testset "conversion of SubString to the same type, issue #25525" begin
x = SubString("ab", 1, 1)
y = convert(SubString{String}, x)
@test y === x
chop("ab") === chop.(["ab"])[1]
Expand Down Expand Up @@ -1170,6 +1167,9 @@ end
apple_uint8 = Vector{UInt8}("Apple")
@test apple_uint8 == [0x41, 0x70, 0x70, 0x6c, 0x65]

apple_uint8 = Array{UInt8}("Apple")
@test apple_uint8 == [0x41, 0x70, 0x70, 0x6c, 0x65]

Base.String(::tstStringType) = "Test"
abstract_apple = tstStringType(apple_uint8)
@test hash(abstract_apple, UInt(1)) == hash("Test", UInt(1))
Expand Down