Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for Base.cwstring #56123

Merged
merged 10 commits into from
Jan 8, 2025
Prev Previous commit
Next Next commit
Added Windows OS check to cwstring testset
  • Loading branch information
rileysheridan committed Nov 9, 2024
commit fb1d111d59cf9a7b700f065736ce9d1845fa8f95
28 changes: 15 additions & 13 deletions test/strings/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1421,17 +1421,19 @@ end
end
end

@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 Base.cwstring(str_2) == UInt16[0x0057, 0x006f, 0x0072, 0x0064, 0x0000]
@test Base.cwstring(str_3) == UInt16[0x0061, 0x0723, 0xd808, 0xdc00, 0x0000]
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 Base.cwstring(str_2) == UInt16[0x0057, 0x006f, 0x0072, 0x0064, 0x0000]
rileysheridan marked this conversation as resolved.
Show resolved Hide resolved
@test Base.cwstring(str_3) == UInt16[0x0061, 0x0723, 0xd808, 0xdc00, 0x0000]
end
end