aboutsummaryrefslogtreecommitdiff
path: root/src/strconv/strconv_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/strconv/strconv_test.go')
-rw-r--r--src/strconv/strconv_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/strconv/strconv_test.go b/src/strconv/strconv_test.go
index 9a007dde4a..0c14236097 100644
--- a/src/strconv/strconv_test.go
+++ b/src/strconv/strconv_test.go
@@ -55,3 +55,34 @@ func TestCountMallocs(t *testing.T) {
}
}
}
+
+func TestErrorPrefixes(t *testing.T) {
+ _, errInt := Atoi("INVALID")
+ _, errBool := ParseBool("INVALID")
+ _, errFloat := ParseFloat("INVALID", 64)
+ _, errInt64 := ParseInt("INVALID", 10, 64)
+ _, errUint64 := ParseUint("INVALID", 10, 64)
+
+ vectors := []struct {
+ err error // Input error
+ want string // Function name wanted
+ }{
+ {errInt, "Atoi"},
+ {errBool, "ParseBool"},
+ {errFloat, "ParseFloat"},
+ {errInt64, "ParseInt"},
+ {errUint64, "ParseUint"},
+ }
+
+ for _, v := range vectors {
+ nerr, ok := v.err.(*NumError)
+ if !ok {
+ t.Errorf("test %s, error was not a *NumError", v.want)
+ continue
+ }
+ if got := nerr.Func; got != v.want {
+ t.Errorf("mismatching Func: got %s, want %s", got, v.want)
+ }
+ }
+
+}