summaryrefslogtreecommitdiff
path: root/src/pkg/expvar/expvar_test.go
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-01-17 12:40:45 +0100
committerOndřej Surý <ondrej@sury.org>2011-01-17 12:40:45 +0100
commit3e45412327a2654a77944249962b3652e6142299 (patch)
treebc3bf69452afa055423cbe0c5cfa8ca357df6ccf /src/pkg/expvar/expvar_test.go
parentc533680039762cacbc37db8dc7eed074c3e497be (diff)
downloadgolang-upstream/2011.01.12.tar.gz
Imported Upstream version 2011.01.12upstream/2011.01.12
Diffstat (limited to 'src/pkg/expvar/expvar_test.go')
-rw-r--r--src/pkg/expvar/expvar_test.go24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/pkg/expvar/expvar_test.go b/src/pkg/expvar/expvar_test.go
index 98cd9c2ea..009f24d1a 100644
--- a/src/pkg/expvar/expvar_test.go
+++ b/src/pkg/expvar/expvar_test.go
@@ -27,6 +27,11 @@ func TestInt(t *testing.T) {
if s := reqs.String(); s != "4" {
t.Errorf("reqs.String() = %q, want \"4\"", s)
}
+
+ reqs.Set(-2)
+ if reqs.i != -2 {
+ t.Errorf("reqs.i = %v, want -2", reqs.i)
+ }
}
func TestString(t *testing.T) {
@@ -76,13 +81,13 @@ func TestMapCounter(t *testing.T) {
t.Error("red.Kind() is not a number.")
}
if x != 3 {
- t.Error("red = %v, want 3", x)
+ t.Errorf("red = %v, want 3", x)
}
}
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)
}
@@ -92,3 +97,16 @@ func TestIntFunc(t *testing.T) {
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)
+ }
+}