Skip to content

Commit 8dc1fa4

Browse files
authored
Merge pull request #43024 from JuliaLang/ksh/chartests
A few tests for Char and transcode
2 parents 9bd6dbc + 5cb1d68 commit 8dc1fa4

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

test/ccall.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,6 +1803,11 @@ ccall_with_undefined_lib() = ccall((:time, xx_nOt_DeFiNeD_xx), Cint, (Ptr{Cvoid}
18031803
@test b16 == b
18041804
end
18051805

1806+
@testset "transcode String to String" begin
1807+
a = "Julia strings and things"
1808+
@test transcode(String, a) === a
1809+
end
1810+
18061811
# issue 33413
18071812
@testset "cglobal lowering" begin
18081813
# crash in cglobal33413_ptrinline[_notype]() specifically requires the library pointer be

test/char.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
@testset "basic properties" begin
44

5+
@test typemax(Char) == reinterpret(Char, typemax(UInt32))
56
@test typemin(Char) == Char(0)
67
@test ndims(Char) == 0
78
@test getindex('a', 1) == 'a'
@@ -248,13 +249,17 @@ Base.codepoint(c::ASCIIChar) = reinterpret(UInt8, c)
248249

249250
@testset "abstractchar" begin
250251
@test AbstractChar('x') === AbstractChar(UInt32('x')) === 'x'
252+
@test convert(AbstractChar, 2.0) == Char(2)
251253

252254
@test isascii(ASCIIChar('x'))
253255
@test ASCIIChar('x') < 'y'
254256
@test ASCIIChar('x') == 'x' === Char(ASCIIChar('x')) === convert(Char, ASCIIChar('x'))
255257
@test ASCIIChar('x')^3 == "xxx"
256258
@test repr(ASCIIChar('x')) == "'x'"
257259
@test string(ASCIIChar('x')) == "x"
260+
@test length(ASCIIChar('x')) == 1
261+
@test !isempty(ASCIIChar('x'))
262+
@test eltype(ASCIIChar) == ASCIIChar
258263
@test_throws MethodError write(IOBuffer(), ASCIIChar('x'))
259264
@test_throws MethodError read(IOBuffer('x'), ASCIIChar)
260265
end

0 commit comments

Comments
 (0)