@@ -12,12 +12,12 @@ func TestArgs(t *testing.T) {
12
12
Dir : "./testdata/args" ,
13
13
Stderr : stderr ,
14
14
Stdout : stdout ,
15
- Args : []string {"status" , "say" , "hi" , "bob" , "count" , "5" , "status" , "wait" , "5ms" , "cough" , "false" },
15
+ Args : []string {"status" , "say" , "hi" , "bob" , "count" , "5" , "status" , "wait" , "5ms" , "cough" , "false" , "doubleIt" , "3.14" },
16
16
}
17
17
code := Invoke (inv )
18
18
if code != 0 {
19
19
t .Log (stderr .String ())
20
- t .Fatalf ("expected 1 , but got %v" , code )
20
+ t .Fatalf ("expected 0 , but got %v" , code )
21
21
}
22
22
actual := stdout .String ()
23
23
expected := `status
@@ -26,6 +26,7 @@ saying hi bob
26
26
status
27
27
waiting 5ms
28
28
not coughing
29
+ 3.1 * 2 = 6.3
29
30
`
30
31
if actual != expected {
31
32
t .Fatalf ("output is not expected:\n %q" , actual )
@@ -101,6 +102,29 @@ func TestBadDurationArg(t *testing.T) {
101
102
}
102
103
}
103
104
105
+ func TestBadFloat64Arg (t * testing.T ) {
106
+ stderr := & bytes.Buffer {}
107
+ stdout := & bytes.Buffer {}
108
+ inv := Invocation {
109
+ Dir : "./testdata/args" ,
110
+ Stderr : stderr ,
111
+ Stdout : stdout ,
112
+ Args : []string {"doubleIt" , "abc123" },
113
+ }
114
+ code := Invoke (inv )
115
+ if code != 2 {
116
+ t .Log ("stderr:" , stderr )
117
+ t .Log ("stdout:" , stdout )
118
+ t .Fatalf ("expected code 2, but got %v" , code )
119
+ }
120
+ actual := stderr .String ()
121
+ expected := "can't convert argument \" abc123\" to float64\n "
122
+
123
+ if actual != expected {
124
+ t .Fatalf ("output is not expected:\n %q" , actual )
125
+ }
126
+ }
127
+
104
128
func TestMissingArgs (t * testing.T ) {
105
129
stderr := & bytes.Buffer {}
106
130
stdout := & bytes.Buffer {}
0 commit comments