aboutsummaryrefslogtreecommitdiff
path: root/tests/core/sys/windows/util.odin
blob: e2ab9cde0d2fe9452966f95fcc48f6e9feea0eaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#+build windows
package test_core_sys_windows

import "base:intrinsics"
import "core:testing"
import win32 "core:sys/windows"

UTF16_Vector :: struct {
	wstr: win32.wstring,
	ustr: string,
}

utf16_vectors := []UTF16_Vector{
	{
		"Hellope, World!",
		"Hellope, World!",
	},
	{
		"Hellope\x00, World!",
		"Hellope",
	},
}

@(test)
utf16_to_utf8_buf_test :: proc(t: ^testing.T) {
	for test in utf16_vectors {
		buf := make([]u8, len(test.ustr))
		defer delete(buf)

		wstr := string16(test.wstr)
		res := win32.utf16_to_utf8_buf(buf[:], transmute([]u16)wstr)
		testing.expect_value(t, res, test.ustr)
	}
}