Fix tests for UTF-16 strings

This commit is contained in:
gingerBill
2025-08-02 13:01:58 +01:00
parent 5aec40e3e0
commit e049dde582
4 changed files with 6 additions and 5 deletions
+1 -1
View File
@@ -145,7 +145,7 @@ LPSTR :: ^CHAR
LPWSTR :: ^WCHAR
OLECHAR :: WCHAR
BSTR :: ^OLECHAR
LPOLESTR :: ^OLECHAR
LPOLESTR :: cstring16
LPCOLESTR :: LPCSTR
LPFILETIME :: ^FILETIME
LPWSABUF :: ^WSABUF
+1 -1
View File
@@ -12,7 +12,7 @@ lcid_to_local :: proc(t: ^testing.T) {
cc := win32.LCIDToLocaleName(lcid, &wname[0], len(wname) - 1, 0)
testing.expectf(t, cc == 6, "%#x (should be: %#x)", u32(cc), 6)
if cc == 0 {return}
str, err := win32.wstring_to_utf8(win32.wstring(&wname), int(cc))
str, err := win32.wstring_to_utf8(win32.wstring(&wname[0]), int(cc))
testing.expectf(t, err == .None, "%v (should be: %x)", err, 0)
exp :: "en-US"
testing.expectf(t, str == exp, "%v (should be: %v)", str, exp)
+2 -2
View File
@@ -9,7 +9,7 @@ import "core:testing"
string_from_clsid :: proc(t: ^testing.T) {
p: win32.LPOLESTR
hr := win32.StringFromCLSID(win32.CLSID_FileOpenDialog, &p)
defer if p != nil {win32.CoTaskMemFree(p)}
defer if p != nil {win32.CoTaskMemFree(rawptr(p))}
testing.expectf(t, win32.SUCCEEDED(hr), "%x (should be: %x)", u32(hr), 0)
testing.expectf(t, p != nil, "%v is nil", p)
@@ -33,7 +33,7 @@ clsid_from_string :: proc(t: ^testing.T) {
string_from_iid :: proc(t: ^testing.T) {
p: win32.LPOLESTR
hr := win32.StringFromIID(win32.IID_IFileDialog, &p)
defer if p != nil {win32.CoTaskMemFree(p)}
defer if p != nil {win32.CoTaskMemFree(rawptr(p))}
testing.expectf(t, win32.SUCCEEDED(hr), "%x (should be: %x)", u32(hr), 0)
testing.expectf(t, p != nil, "%v is nil", p)
+2 -1
View File
@@ -27,7 +27,8 @@ utf16_to_utf8_buf_test :: proc(t: ^testing.T) {
buf := make([]u8, len(test.ustr))
defer delete(buf)
res := win32.utf16_to_utf8_buf(buf[:], test.wstr[:len(test.ustr)])
wstr := string16(test.wstr)
res := win32.utf16_to_utf8_buf(buf[:], transmute([]u16)wstr)
testing.expect_value(t, res, test.ustr)
}
}