MCPcopy Index your code
hub / github.com/foxcpp/maddy / TestMapBool

Function TestMapBool

framework/config/map_test.go:357–399  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

355}
356
357func TestMapBool(t *testing.T) {
358 cfg := Node{
359 Children: []Node{
360 {
361 Name: "foo",
362 },
363 {
364 Name: "bar",
365 Args: []string{"yes"},
366 },
367 {
368 Name: "baz",
369 Args: []string{"no"},
370 },
371 },
372 }
373
374 m := NewMap(nil, cfg)
375
376 foo, bar, baz, boo := false, false, false, false
377 m.Bool("foo", false, false, &foo)
378 m.Bool("bar", false, false, &bar)
379 m.Bool("baz", false, false, &baz)
380 m.Bool("boo", false, false, &boo)
381
382 _, err := m.Process()
383 if err != nil {
384 t.Fatalf("Unexpected failure: %v", err)
385 }
386
387 if !foo {
388 t.Errorf("Incorrect value stored in variable foo, want true, got false")
389 }
390 if !bar {
391 t.Errorf("Incorrect value stored in variable bar, want true, got false")
392 }
393 if baz {
394 t.Errorf("Incorrect value stored in variable baz, want false, got true")
395 }
396 if boo {
397 t.Errorf("Incorrect value stored in variable boo, want false, got true")
398 }
399}
400
401func TestParseDataSize(t *testing.T) {
402 check := func(s string, ok bool, expected int) {

Callers

nothing calls this directly

Calls 3

BoolMethod · 0.95
ProcessMethod · 0.95
NewMapFunction · 0.85

Tested by

no test coverage detected