/usr/share/julia/test/unicode/utf8.jl is in julia-common 0.4.7-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | # This file is a part of Julia. License is MIT: http://julialang.org/license
## Test for CESU-8 sequences
let ch = 0x10000
for hichar = 0xd800:0xdbff
for lochar = 0xdc00:0xdfff
@test convert(UTF8String, utf8(Char[hichar, lochar]).data) == string(Char(ch))
ch += 1
end
end
end
let str = UTF8String(b"this is a test\xed\x80")
@test next(str, 15) == ('\ufffd', 16)
@test_throws BoundsError getindex(str, 0:3)
@test_throws BoundsError getindex(str, 17:18)
@test_throws BoundsError getindex(str, 2:17)
@test_throws UnicodeError getindex(str, 16:17)
@test string(Char(0x110000)) == "\ufffd"
sa = SubString{ASCIIString}(ascii("This is a silly test"), 1, 14)
s8 = convert(SubString{UTF8String}, sa)
@test typeof(s8) == SubString{UTF8String}
@test s8 == "This is a sill"
@test convert(UTF8String, b"this is a test\xed\x80\x80") == "this is a test\ud000"
end
## Reverse of UTF8String
@test reverse(UTF8String("")) == ""
@test reverse(UTF8String("a")) == "a"
@test reverse(UTF8String("abc")) == "cba"
@test reverse(UTF8String("xyz\uff\u800\uffff\U10ffff")) == "\U10ffff\uffff\u800\uffzyx"
for str in (b"xyz\xc1", b"xyz\xd0", b"xyz\xe0", b"xyz\xed\x80", b"xyz\xf0", b"xyz\xf0\x80", b"xyz\xf0\x80\x80")
@test_throws UnicodeError reverse(UTF8String(str))
end
## Specifically check UTF-8 string whose lead byte is same as a surrogate
@test convert(UTF8String,b"\xed\x9f\xbf") == "\ud7ff"
|