summaryrefslogtreecommitdiffstats
path: root/libgo/go/flag/flag_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/flag/flag_test.go')
-rw-r--r--libgo/go/flag/flag_test.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/libgo/go/flag/flag_test.go b/libgo/go/flag/flag_test.go
index 698c15f2c58..a9561f269f9 100644
--- a/libgo/go/flag/flag_test.go
+++ b/libgo/go/flag/flag_test.go
@@ -5,10 +5,12 @@
package flag_test
import (
+ "bytes"
. "flag"
"fmt"
"os"
"sort"
+ "strings"
"testing"
"time"
)
@@ -206,6 +208,17 @@ func TestUserDefined(t *testing.T) {
}
}
+func TestSetOutput(t *testing.T) {
+ var flags FlagSet
+ var buf bytes.Buffer
+ flags.SetOutput(&buf)
+ flags.Init("test", ContinueOnError)
+ flags.Parse([]string{"-unknown"})
+ if out := buf.String(); !strings.Contains(out, "-unknown") {
+ t.Logf("expected output mentioning unknown; got %q", out)
+ }
+}
+
// This tests that one can reset the flags. This still works but not well, and is
// superseded by FlagSet.
func TestChangingArgs(t *testing.T) {
OpenPOWER on IntegriCloud