(t *testing.T)
| 163 | } |
| 164 | |
| 165 | func TestInt(t *testing.T) { |
| 166 | tests := []struct { |
| 167 | name string |
| 168 | key string |
| 169 | value int |
| 170 | expected map[string]any |
| 171 | }{ |
| 172 | { |
| 173 | name: "positive int", |
| 174 | key: "count", |
| 175 | value: 42, |
| 176 | expected: map[string]any{ |
| 177 | "count": 42.0, |
| 178 | }, |
| 179 | }, |
| 180 | { |
| 181 | name: "negative int", |
| 182 | key: "negative", |
| 183 | value: -100, |
| 184 | expected: map[string]any{ |
| 185 | "negative": -100.0, |
| 186 | }, |
| 187 | }, |
| 188 | { |
| 189 | name: "zero int", |
| 190 | key: "zero", |
| 191 | value: 0, |
| 192 | expected: map[string]any{ |
| 193 | "zero": 0.0, |
| 194 | }, |
| 195 | }, |
| 196 | } |
| 197 | |
| 198 | for _, tt := range tests { |
| 199 | t.Run(tt.name, func(t *testing.T) { |
| 200 | // Test memory allocations |
| 201 | allocs := testing.AllocsPerRun(100, func() { |
| 202 | _ = Int(tt.key, tt.value) |
| 203 | }) |
| 204 | require.Equal(t, float64(0), allocs, "Int() should not allocate memory") |
| 205 | |
| 206 | // Test output format |
| 207 | param := Int(tt.key, tt.value) |
| 208 | |
| 209 | jw := contentlog.NewJSONWriter() |
| 210 | defer jw.Release() |
| 211 | |
| 212 | jw.BeginObject() |
| 213 | param.WriteValueTo(jw) |
| 214 | jw.EndObject() |
| 215 | |
| 216 | var result map[string]any |
| 217 | |
| 218 | require.NoError(t, json.Unmarshal(jw.GetBufferForTesting(), &result)) |
| 219 | require.Equal(t, tt.expected, result) |
| 220 | }) |
| 221 | } |
| 222 | } |
nothing calls this directly
no test coverage detected