MCPcopy
hub / github.com/spf13/pflag / TestVisitFlagOrder

Function TestVisitFlagOrder

flag_test.go:1381–1397  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1379}
1380
1381func TestVisitFlagOrder(t *testing.T) {
1382 fs := NewFlagSet("TestVisitFlagOrder", ContinueOnError)
1383 fs.SortFlags = false
1384 names := []string{"C", "B", "A", "D"}
1385 for _, name := range names {
1386 fs.Bool(name, false, "")
1387 fs.Set(name, "true")
1388 }
1389
1390 i := 0
1391 fs.Visit(func(f *Flag) {
1392 if names[i] != f.Name {
1393 t.Errorf("Incorrect order. Expected %v, got %v", names[i], f.Name)
1394 }
1395 i++
1396 })
1397}

Callers

nothing calls this directly

Calls 4

BoolMethod · 0.95
SetMethod · 0.95
VisitMethod · 0.95
NewFlagSetFunction · 0.85

Tested by

no test coverage detected