Skip to content

Commit

Permalink
Add tests for Base.cwstring (#56123)
Browse files Browse the repository at this point in the history
Co-authored-by: Sukera <11753998+Seelengrab@users.noreply.github.com>
Co-authored-by: Lilith Orion Hafner <lilithhafner@gmail.com>
  • Loading branch information
3 people authored Jan 8, 2025
1 parent b8ab9f3 commit 98dc249
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/strings/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1423,3 +1423,20 @@ end
@test transcode(String, transcode(UInt8, transcode(UInt16, str))) == str
end
end

if Sys.iswindows()
@testset "cwstring" begin
# empty string
str_0 = ""
# string with embedded NUL character
str_1 = "Au\000B"
# string with terminating NUL character
str_2 = "Wordu\000"
# "Regular" string with UTF-8 characters of differing byte counts
str_3 = "aܣ𒀀"
@test Base.cwstring(str_0) == UInt16[0x0000]
@test_throws ArgumentError Base.cwstring(str_1)
@test_throws ArgumentError Base.cwstring(str_2)
@test Base.cwstring(str_3) == UInt16[0x0061, 0x0723, 0xd808, 0xdc00, 0x0000]
end
end

0 comments on commit 98dc249

Please sign in to comment.