(t *testing.T)
| 623 | } |
| 624 | |
| 625 | func TestApplyLocalBoolOpt(t *testing.T) { |
| 626 | tests := []struct { |
| 627 | localOpt map[string]bool |
| 628 | globalOpt bool |
| 629 | e setLocalExpr |
| 630 | exp bool |
| 631 | }{ |
| 632 | {map[string]bool{}, false, setLocalExpr{"/", "feature", ""}, true}, |
| 633 | {map[string]bool{}, false, setLocalExpr{"/", "feature", "true"}, true}, |
| 634 | {map[string]bool{}, false, setLocalExpr{"/", "feature", "false"}, false}, |
| 635 | {map[string]bool{}, false, setLocalExpr{"/", "nofeature", ""}, false}, |
| 636 | {map[string]bool{}, true, setLocalExpr{"/", "feature!", ""}, false}, |
| 637 | {map[string]bool{}, false, setLocalExpr{"/", "feature!", ""}, true}, |
| 638 | {map[string]bool{"/": true}, false, setLocalExpr{"/", "feature", ""}, true}, |
| 639 | {map[string]bool{"/": true}, false, setLocalExpr{"/", "feature", "true"}, true}, |
| 640 | {map[string]bool{"/": true}, false, setLocalExpr{"/", "feature", "false"}, false}, |
| 641 | {map[string]bool{"/": true}, false, setLocalExpr{"/", "nofeature", ""}, false}, |
| 642 | {map[string]bool{"/": true}, true, setLocalExpr{"/", "feature!", ""}, false}, |
| 643 | {map[string]bool{"/": true}, false, setLocalExpr{"/", "feature!", ""}, false}, |
| 644 | {map[string]bool{"/": false}, false, setLocalExpr{"/", "feature", ""}, true}, |
| 645 | {map[string]bool{"/": false}, false, setLocalExpr{"/", "feature", "true"}, true}, |
| 646 | {map[string]bool{"/": false}, false, setLocalExpr{"/", "feature", "false"}, false}, |
| 647 | {map[string]bool{"/": false}, false, setLocalExpr{"/", "nofeature", ""}, false}, |
| 648 | {map[string]bool{"/": false}, true, setLocalExpr{"/", "feature!", ""}, true}, |
| 649 | {map[string]bool{"/": false}, false, setLocalExpr{"/", "feature!", ""}, true}, |
| 650 | } |
| 651 | |
| 652 | for _, test := range tests { |
| 653 | testStr := fmt.Sprintf("%v", test) |
| 654 | if err := applyLocalBoolOpt(test.localOpt, test.globalOpt, &test.e); err != nil { |
| 655 | t.Errorf("at test '%s' expected '%t' but got an error '%s'", testStr, test.exp, err) |
| 656 | continue |
| 657 | } |
| 658 | result := test.localOpt[test.e.path] |
| 659 | if result != test.exp { |
| 660 | t.Errorf("at test '%s' expected '%t' but got '%t'", testStr, test.exp, result) |
| 661 | } |
| 662 | } |
| 663 | } |
nothing calls this directly
no test coverage detected