aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaytan Laats <laytanlaats@hotmail.com>2024-07-15 19:27:48 +0200
committerLaytan Laats <laytanlaats@hotmail.com>2024-07-15 19:27:48 +0200
commitf362e0fa20b6deedae24bcaeb518efed9de7f6b6 (patch)
treec9629b35ed5861dab2ccc39d9e6dd349883ebb8b
parentd4d910bcfcf96a6e2e393f56a905e40608d6a575 (diff)
add test for leaking struct tag into elems
-rw-r--r--tests/core/fmt/test_core_fmt.odin16
1 files changed, 16 insertions, 0 deletions
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)