| // Copyright 2017 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| func TestIntFromStr(t *testing.T) { |
| {"User ID: 98403", 98403}, |
| {"1234 User 5431 ID", 1234}, |
| {"Stardate 153.2415", 153}, |
| for _, tc := range testcases { |
| r, ok := intFromStr(tc.s) |
| t.Errorf("intFromStr(%q) = %v", tc.s, ok) |
| t.Errorf("intFromStr(%q) = %d; want %d", tc.s, r, tc.i) |
| _, ok := intFromStr(noInt) |
| t.Errorf("intFromStr(%q) = %v; want false", noInt, ok) |