(t *testing.T)
| 169 | } |
| 170 | |
| 171 | func TestDispenser_Args(t *testing.T) { |
| 172 | var s1, s2, s3 string |
| 173 | input := `dir1 arg1 arg2 arg3 |
| 174 | dir2 arg4 arg5 |
| 175 | dir3 arg6 arg7 |
| 176 | dir4` |
| 177 | d := NewTestDispenser(input) |
| 178 | |
| 179 | d.Next() // dir1 |
| 180 | |
| 181 | // As many strings as arguments |
| 182 | if all := d.Args(&s1, &s2, &s3); !all { |
| 183 | t.Error("Args(): Expected true, got false") |
| 184 | } |
| 185 | if s1 != "arg1" { |
| 186 | t.Errorf("Args(): Expected s1 to be 'arg1', got '%s'", s1) |
| 187 | } |
| 188 | if s2 != "arg2" { |
| 189 | t.Errorf("Args(): Expected s2 to be 'arg2', got '%s'", s2) |
| 190 | } |
| 191 | if s3 != "arg3" { |
| 192 | t.Errorf("Args(): Expected s3 to be 'arg3', got '%s'", s3) |
| 193 | } |
| 194 | |
| 195 | d.Next() // dir2 |
| 196 | |
| 197 | // More strings than arguments |
| 198 | if all := d.Args(&s1, &s2, &s3); all { |
| 199 | t.Error("Args(): Expected false, got true") |
| 200 | } |
| 201 | if s1 != "arg4" { |
| 202 | t.Errorf("Args(): Expected s1 to be 'arg4', got '%s'", s1) |
| 203 | } |
| 204 | if s2 != "arg5" { |
| 205 | t.Errorf("Args(): Expected s2 to be 'arg5', got '%s'", s2) |
| 206 | } |
| 207 | if s3 != "arg3" { |
| 208 | t.Errorf("Args(): Expected s3 to be unchanged ('arg3'), instead got '%s'", s3) |
| 209 | } |
| 210 | |
| 211 | // (quick cursor check just for kicks and giggles) |
| 212 | if d.cursor != 6 { |
| 213 | t.Errorf("Cursor should be 6, but is %d", d.cursor) |
| 214 | } |
| 215 | |
| 216 | d.Next() // dir3 |
| 217 | |
| 218 | // More arguments than strings |
| 219 | if all := d.Args(&s1); !all { |
| 220 | t.Error("Args(): Expected true, got false") |
| 221 | } |
| 222 | if s1 != "arg6" { |
| 223 | t.Errorf("Args(): Expected s1 to be 'arg6', got '%s'", s1) |
| 224 | } |
| 225 | |
| 226 | d.Next() // dir4 |
| 227 | |
| 228 | // No arguments or strings |
nothing calls this directly
no test coverage detected