aboutsummaryrefslogtreecommitdiff
path: root/float32_slice_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'float32_slice_test.go')
-rw-r--r--float32_slice_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/float32_slice_test.go b/float32_slice_test.go
index 2429c8f..1e9a942 100644
--- a/float32_slice_test.go
+++ b/float32_slice_test.go
@@ -156,6 +156,29 @@ func TestF32SWithDefault(t *testing.T) {
}
}
+func TestF32SAsSliceValue(t *testing.T) {
+ var f32s []float32
+ f := setUpF32SFlagSet(&f32s)
+
+ in := []string{"1.0", "2.0"}
+ argfmt := "--f32s=%s"
+ arg1 := fmt.Sprintf(argfmt, in[0])
+ arg2 := fmt.Sprintf(argfmt, in[1])
+ err := f.Parse([]string{arg1, arg2})
+ if err != nil {
+ t.Fatal("expected no error; got", err)
+ }
+
+ f.VisitAll(func(f *Flag) {
+ if val, ok := f.Value.(SliceValue); ok {
+ _ = val.Replace([]string{"3.1"})
+ }
+ })
+ if len(f32s) != 1 || f32s[0]!= 3.1 {
+ t.Fatalf("Expected ss to be overwritten with '3.1', but got: %v", f32s)
+ }
+}
+
func TestF32SCalledTwice(t *testing.T) {
var f32s []float32
f := setUpF32SFlagSet(&f32s)