|
285 | 285 | # Test unsafe_convert
|
286 | 286 | type A; end
|
287 | 287 | x = "abc"
|
288 |
| -@test @compat String(Compat.unsafe_convert(Ptr{UInt8}, x)) == x |
| 288 | +@test @compat String(unsafe_string(Compat.unsafe_convert(Ptr{UInt8}, x))) == x |
289 | 289 | Compat.unsafe_convert(::Ptr{A}, x) = x
|
290 | 290 | @test Compat.unsafe_convert(pointer([A()]), 1) == 1
|
291 | 291 |
|
@@ -398,36 +398,41 @@ let A = [1.0 2.0; 3.0 4.0]
|
398 | 398 | end
|
399 | 399 |
|
400 | 400 | # Cstring
|
401 |
| -let s = "foo", w = wstring("foo") |
402 |
| - @test reinterpret(Ptr{Cchar}, Compat.unsafe_convert(Cstring, s)) == pointer(s) |
| 401 | +let s = "foo" |
| 402 | + # note: need cconvert in 0.5 because of JuliaLang/julia#16893 |
| 403 | + @test reinterpret(Ptr{Cchar}, Compat.unsafe_convert(Cstring, VERSION < v"0.4" ? s : Base.cconvert(Cstring, s))) == pointer(s) |
403 | 404 | if VERSION < v"0.5.0-dev+4859"
|
404 |
| - @test reinterpret(Ptr{Cwchar_t}, Compat.unsafe_convert(Cwstring, w)) == pointer(w) |
| 405 | + let w = wstring("foo") |
| 406 | + @test reinterpret(Ptr{Cwchar_t}, Compat.unsafe_convert(Cwstring, w)) == pointer(w) |
| 407 | + end |
405 | 408 | end
|
406 | 409 | end
|
407 | 410 |
|
408 | 411 | # fma and muladd
|
409 | 412 | @test fma(3,4,5) == 3*4+5 == muladd(3,4,5)
|
410 | 413 |
|
411 |
| -# is_valid_utf32 |
412 |
| -s = utf32("abc") |
413 |
| -@test isvalid(s) |
414 |
| -s = utf32(UInt32[65,0x110000]) |
415 |
| -@test !isvalid(s) |
416 |
| - |
417 |
| -# isvalid |
418 |
| -let s = "abcdef", u8 = "abcdef\uff", u16 = utf16(u8), u32 = utf32(u8), |
419 |
| - bad32 = utf32(UInt32[65,0x110000]), badch = Char[0x110000][1] |
420 |
| - |
421 |
| - @test !isvalid(bad32) |
422 |
| - @test !isvalid(badch) |
| 414 | +if VERSION < v"0.5.0-dev+5271" |
| 415 | + # is_valid_utf32 |
| 416 | + s = utf32("abc") |
423 | 417 | @test isvalid(s)
|
424 |
| - @test isvalid(u8) |
425 |
| - @test isvalid(u16) |
426 |
| - @test isvalid(u32) |
427 |
| - @test isvalid(Compat.ASCIIString, s) |
428 |
| - @test isvalid(Compat.UTF8String, u8) |
429 |
| - @test isvalid(UTF16String, u16) |
430 |
| - @test isvalid(UTF32String, u32) |
| 418 | + s = utf32(UInt32[65,0x110000]) |
| 419 | + @test !isvalid(s) |
| 420 | + |
| 421 | + # isvalid |
| 422 | + let s = "abcdef", u8 = "abcdef\uff", u16 = utf16(u8), u32 = utf32(u8), |
| 423 | + bad32 = utf32(UInt32[65,0x110000]), badch = Char[0x110000][1] |
| 424 | + |
| 425 | + @test !isvalid(bad32) |
| 426 | + @test !isvalid(badch) |
| 427 | + @test isvalid(s) |
| 428 | + @test isvalid(u8) |
| 429 | + @test isvalid(u16) |
| 430 | + @test isvalid(u32) |
| 431 | + @test isvalid(Compat.ASCIIString, s) |
| 432 | + @test isvalid(Compat.UTF8String, u8) |
| 433 | + @test isvalid(UTF16String, u16) |
| 434 | + @test isvalid(UTF32String, u32) |
| 435 | + end |
431 | 436 | end
|
432 | 437 |
|
433 | 438 | if VERSION < v"0.5.0-dev+907"
|
@@ -1190,8 +1195,8 @@ let io = IOBuffer(), s = "hello"
|
1190 | 1195 | @test @compat String(s.data) == s
|
1191 | 1196 | write(io, s)
|
1192 | 1197 | @test @compat String(io) == s
|
1193 |
| - @test @compat String(pointer(s.data)) == s |
1194 |
| - @test @compat String(pointer(s.data),length(s.data)) == s |
| 1198 | + @test unsafe_string(pointer(s.data)) == s |
| 1199 | + @test unsafe_string(pointer(s.data),length(s.data)) == s |
1195 | 1200 | @test string(s, s, s) == "hellohellohello"
|
1196 | 1201 | @test @compat(String(s)) == s
|
1197 | 1202 | @test String == @compat(Union{Compat.UTF8String,Compat.ASCIIString})
|
@@ -1246,5 +1251,5 @@ end
|
1246 | 1251 |
|
1247 | 1252 | # Add test for Base.view
|
1248 | 1253 | let a = rand(10,10)
|
1249 |
| - @test view(a, :, 1) == a[:,1] |
| 1254 | + @test view(a, :, 1) == a[:,1] |
1250 | 1255 | end
|
0 commit comments