From 98dc249622fa23e073419caeaa1213c69e1a0295 Mon Sep 17 00:00:00 2001 From: rileysheridan Date: Wed, 8 Jan 2025 08:26:02 -0500 Subject: [PATCH] Add tests for Base.cwstring (#56123) Co-authored-by: Sukera <11753998+Seelengrab@users.noreply.github.com> Co-authored-by: Lilith Orion Hafner --- test/strings/basic.jl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/strings/basic.jl b/test/strings/basic.jl index 3fc611a660975..f90ce8c697ed8 100644 --- a/test/strings/basic.jl +++ b/test/strings/basic.jl @@ -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