(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestString(t *testing.T) { |
| 16 | tests := []struct { |
| 17 | name string |
| 18 | key string |
| 19 | value string |
| 20 | expected map[string]any |
| 21 | }{ |
| 22 | { |
| 23 | name: "simple string", |
| 24 | key: "message", |
| 25 | value: "hello world", |
| 26 | expected: map[string]any{ |
| 27 | "message": "hello world", |
| 28 | }, |
| 29 | }, |
| 30 | { |
| 31 | name: "empty string", |
| 32 | key: "empty", |
| 33 | value: "", |
| 34 | expected: map[string]any{ |
| 35 | "empty": "", |
| 36 | }, |
| 37 | }, |
| 38 | { |
| 39 | name: "unicode string", |
| 40 | key: "unicode", |
| 41 | value: "😄🚀🎉", |
| 42 | expected: map[string]any{ |
| 43 | "unicode": "😄🚀🎉", |
| 44 | }, |
| 45 | }, |
| 46 | { |
| 47 | name: "string with special chars", |
| 48 | key: "special", |
| 49 | value: "hello\nworld\r\t\b\f", |
| 50 | expected: map[string]any{ |
| 51 | "special": "hello\nworld\r\t\b\f", |
| 52 | }, |
| 53 | }, |
| 54 | { |
| 55 | name: "string with control chars", |
| 56 | key: "control", |
| 57 | value: "hello\x00world\x07test", |
| 58 | expected: map[string]any{ |
| 59 | "control": "hello\x00world\x07test", |
| 60 | }, |
| 61 | }, |
| 62 | } |
| 63 | |
| 64 | for _, tt := range tests { |
| 65 | t.Run(tt.name, func(t *testing.T) { |
| 66 | // Test memory allocations |
| 67 | allocs := testing.AllocsPerRun(100, func() { |
| 68 | _ = String(tt.key, tt.value) |
| 69 | }) |
| 70 | require.Equal(t, float64(0), allocs, "String() should not allocate memory") |
| 71 | |
| 72 | // Test output format |
nothing calls this directly
no test coverage detected