From f362e0fa20b6deedae24bcaeb518efed9de7f6b6 Mon Sep 17 00:00:00 2001 From: Laytan Laats Date: Mon, 15 Jul 2024 19:27:48 +0200 Subject: [PATCH] add test for leaking struct tag into elems --- tests/core/fmt/test_core_fmt.odin | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/core/fmt/test_core_fmt.odin b/tests/core/fmt/test_core_fmt.odin index 49142e24d..3a1eb37e7 100644 --- a/tests/core/fmt/test_core_fmt.odin +++ b/tests/core/fmt/test_core_fmt.odin @@ -372,6 +372,22 @@ test_odin_value_export :: proc(t: ^testing.T) { } } +@(test) +leaking_struct_tag :: proc(t: ^testing.T) { + My_Struct :: struct { + names: [^]string `fmt:"v,name_count"`, + name_count: int, + } + + name := "hello?" + foo := My_Struct { + names = &name, + name_count = 1, + } + + check(t, "My_Struct{names = [\"hello?\"], name_count = 1}", "%v", foo) +} + @(private) check :: proc(t: ^testing.T, exp: string, format: string, args: ..any, loc := #caller_location) { got := fmt.tprintf(format, ..args)