(t *testing.T)
| 30 | } |
| 31 | |
| 32 | func TestIntVar(t *testing.T) { |
| 33 | var result int |
| 34 | IntVar(&result, "nonexistent", 15) |
| 35 | Parse() |
| 36 | |
| 37 | if result != 15 { |
| 38 | t.Fatalf("expected result=15, got result=%d", result) |
| 39 | } |
| 40 | |
| 41 | err := os.Setenv("int-key", "25") |
| 42 | if err != nil { |
| 43 | t.Fatal("unexpected error", err) |
| 44 | } |
| 45 | |
| 46 | IntVar(&result, "int-key", 15) |
| 47 | Parse() |
| 48 | |
| 49 | if result != 25 { |
| 50 | t.Fatalf("expected result=25, got result=%d", result) |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | func TestBool(t *testing.T) { |
| 55 | result := Bool("nonexistent", true) |