Skip to content

Commit 98dc249

Browse files
rileysheridanSeelengrabLilithHafner
authored
Add tests for Base.cwstring (#56123)
Co-authored-by: Sukera <[email protected]> Co-authored-by: Lilith Orion Hafner <[email protected]>
1 parent b8ab9f3 commit 98dc249

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/strings/basic.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,3 +1423,20 @@ end
14231423
@test transcode(String, transcode(UInt8, transcode(UInt16, str))) == str
14241424
end
14251425
end
1426+
1427+
if Sys.iswindows()
1428+
@testset "cwstring" begin
1429+
# empty string
1430+
str_0 = ""
1431+
# string with embedded NUL character
1432+
str_1 = "Au\000B"
1433+
# string with terminating NUL character
1434+
str_2 = "Wordu\000"
1435+
# "Regular" string with UTF-8 characters of differing byte counts
1436+
str_3 = "aܣ𒀀"
1437+
@test Base.cwstring(str_0) == UInt16[0x0000]
1438+
@test_throws ArgumentError Base.cwstring(str_1)
1439+
@test_throws ArgumentError Base.cwstring(str_2)
1440+
@test Base.cwstring(str_3) == UInt16[0x0061, 0x0723, 0xd808, 0xdc00, 0x0000]
1441+
end
1442+
end

0 commit comments

Comments
 (0)