expvar: quote StringFunc output, same as String output.
R=adg
CC=golang-dev
https://golang.org/cl/3797041
diff --git a/src/pkg/expvar/expvar_test.go b/src/pkg/expvar/expvar_test.go
index 3dfc55a..009f24d 100644
--- a/src/pkg/expvar/expvar_test.go
+++ b/src/pkg/expvar/expvar_test.go
@@ -86,8 +86,8 @@
}
func TestIntFunc(t *testing.T) {
- x := int(4)
- ix := IntFunc(func() int64 { return int64(x) })
+ x := int64(4)
+ ix := IntFunc(func() int64 { return x })
if s := ix.String(); s != "4" {
t.Errorf("ix.String() = %v, want 4", s)
}
@@ -97,3 +97,16 @@
t.Errorf("ix.String() = %v, want 5", s)
}
}
+
+func TestStringFunc(t *testing.T) {
+ x := "hello"
+ sx := StringFunc(func() string { return x })
+ if s, exp := sx.String(), `"hello"`; s != exp {
+ t.Errorf(`sx.String() = %q, want %q`, s, exp)
+ }
+
+ x = "goodbye"
+ if s, exp := sx.String(), `"goodbye"`; s != exp {
+ t.Errorf(`sx.String() = %q, want %q`, s, exp)
+ }
+}