(t *testing.T)
| 593 | } |
| 594 | |
| 595 | func TestApplyBoolOpt(t *testing.T) { |
| 596 | tests := []struct { |
| 597 | opt bool |
| 598 | e setExpr |
| 599 | exp bool |
| 600 | }{ |
| 601 | {true, setExpr{"feature", ""}, true}, |
| 602 | {true, setExpr{"feature", "true"}, true}, |
| 603 | {true, setExpr{"feature", "false"}, false}, |
| 604 | {false, setExpr{"feature", ""}, true}, |
| 605 | {false, setExpr{"feature", "true"}, true}, |
| 606 | {false, setExpr{"feature", "false"}, false}, |
| 607 | {true, setExpr{"nofeature", ""}, false}, |
| 608 | {false, setExpr{"nofeature", ""}, false}, |
| 609 | {true, setExpr{"feature!", ""}, false}, |
| 610 | {false, setExpr{"feature!", ""}, true}, |
| 611 | } |
| 612 | |
| 613 | for _, test := range tests { |
| 614 | testStr := fmt.Sprintf("%v", test) |
| 615 | if err := applyBoolOpt(&test.opt, &test.e); err != nil { |
| 616 | t.Errorf("at test '%s' expected '%t' but got an error '%s'", testStr, test.exp, err) |
| 617 | continue |
| 618 | } |
| 619 | if test.opt != test.exp { |
| 620 | t.Errorf("at test '%s' expected '%t' but got '%t'", testStr, test.exp, test.opt) |
| 621 | } |
| 622 | } |
| 623 | } |
| 624 | |
| 625 | func TestApplyLocalBoolOpt(t *testing.T) { |
| 626 | tests := []struct { |
nothing calls this directly
no test coverage detected