MCPcopy
hub / github.com/kopia/kopia / TestBool

Function TestBool

internal/contentlog/logparam/logparam_test.go:283–332  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

281}
282
283func TestBool(t *testing.T) {
284 tests := []struct {
285 name string
286 key string
287 value bool
288 expected map[string]any
289 }{
290 {
291 name: "true bool",
292 key: "enabled",
293 value: true,
294 expected: map[string]any{
295 "enabled": true,
296 },
297 },
298 {
299 name: "false bool",
300 key: "disabled",
301 value: false,
302 expected: map[string]any{
303 "disabled": false,
304 },
305 },
306 }
307
308 for _, tt := range tests {
309 t.Run(tt.name, func(t *testing.T) {
310 // Test memory allocations
311 allocs := testing.AllocsPerRun(100, func() {
312 _ = Bool(tt.key, tt.value)
313 })
314 require.Equal(t, float64(0), allocs, "Bool() should not allocate memory")
315
316 // Test output format
317 param := Bool(tt.key, tt.value)
318
319 jw := contentlog.NewJSONWriter()
320 defer jw.Release()
321
322 jw.BeginObject()
323 param.WriteValueTo(jw)
324 jw.EndObject()
325
326 var result map[string]any
327
328 require.NoError(t, json.Unmarshal(jw.GetBufferForTesting(), &result))
329 require.Equal(t, tt.expected, result)
330 })
331 }
332}
333
334func TestTime(t *testing.T) {
335 now := clock.Now()

Callers

nothing calls this directly

Calls 9

ReleaseMethod · 0.95
BeginObjectMethod · 0.95
EndObjectMethod · 0.95
GetBufferForTestingMethod · 0.95
NewJSONWriterFunction · 0.92
BoolFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
WriteValueToMethod · 0.65

Tested by

no test coverage detected