mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
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:
committed by
Christoffer Lerno
parent
d2a461d270
commit
177df6321a
28
test/unit/regression/wstring.c3
Normal file
28
test/unit/regression/wstring.c3
Normal 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 });
|
||||
}
|
||||
Reference in New Issue
Block a user