From 99442fa39034d5a3b4e10464e0284ac6f169371b Mon Sep 17 00:00:00 2001 From: Wachiraphol Yingamphol Date: Mon, 6 Apr 2026 15:06:02 +0700 Subject: [PATCH] add proper test for thread names --- tests/core/thread/test_core_thread.odin | 38 ++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/tests/core/thread/test_core_thread.odin b/tests/core/thread/test_core_thread.odin index 0b77ad511..87c3be942 100644 --- a/tests/core/thread/test_core_thread.odin +++ b/tests/core/thread/test_core_thread.odin @@ -49,4 +49,40 @@ poly_data_test :: proc(_t: ^testing.T) { defer free(t4) thread.join_multiple(t1, t2, t3, t4) -} \ No newline at end of file +} + +@(test) +name_test :: proc(_t: ^testing.T) { + @static name_test_t: ^testing.T + @static main_wait := true + @static child_wait := true + name_test_t = _t + + t := thread.create_and_start(name = "test_name", fn = proc() { + main_wait = false + + for (child_wait) {} + + n, err := thread.get_name() + defer if err != nil { + delete(n) + } + testing.expect(name_test_t, err == nil, "thread name allocation failed") + testing.expect(name_test_t, n == "test_name","thread name on self did not match") + + }) + defer free(t) + + for (main_wait) {} + + n, err := thread.get_name(t) + defer if err != nil { + delete(n) + } + testing.expect(name_test_t, err == nil, "thread name allocation failed") + testing.expect(name_test_t, n == "test_name","thread name on main did not match") + + child_wait = false + + thread.join(t) +}