add test file for wide string constants

add full UTF-8 to wide-str language capabilities
move wstr language constant expressions to builtins and adjust test cases
This commit is contained in:
Zack Puhl
2025-02-12 19:59:01 -05:00
committed by Christoffer Lerno
parent d2a461d270
commit 177df6321a
12 changed files with 223 additions and 25 deletions

View File

@@ -0,0 +1,28 @@
module std::string::wstring_test;
import std;
WString a = @wstring("Hellø");
Char16[] x = @char16("Är du där?");
Char32[] x2 = @char32("你好");
fn void sanity_checks() @test
{
test::eq(a[:6], (Char16[]) { 'H', 'e', 'l', 'l', 'ø', 0 });
test::eq(x, "Är du där?".to_temp_utf16()!!);
test::eq(x2, "你好".to_temp_utf32()!!);
}
fn void test_get_value() @test
{
test::eq((ushort)'Ä', $$wstr16("ÅÄÖ")[1]);
const uint VAL = $$wstr32("XYZ👍ABC")[3];
test::eq((uint)'👍', VAL);
}
fn void lengths() @test
{
test::eq($$wstr16("ABC").len, 4);
test::eq($$wstr16("ABC", false).len, 3);
Char16[?] w = $$wstr16("ÅÄÖ");
test::eq(w, (Char16[?]) { 'Å', 'Ä', 'Ö', 0 });
}