aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/rcrowley/go-metrics/gauge_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'Godeps/_workspace/src/github.com/rcrowley/go-metrics/gauge_test.go')
-rw-r--r--Godeps/_workspace/src/github.com/rcrowley/go-metrics/gauge_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/rcrowley/go-metrics/gauge_test.go b/Godeps/_workspace/src/github.com/rcrowley/go-metrics/gauge_test.go
new file mode 100644
index 000000000..508496291
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/rcrowley/go-metrics/gauge_test.go
@@ -0,0 +1,37 @@
+package metrics
+
+import "testing"
+
+func BenchmarkGuage(b *testing.B) {
+ g := NewGauge()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ g.Update(int64(i))
+ }
+}
+
+func TestGauge(t *testing.T) {
+ g := NewGauge()
+ g.Update(int64(47))
+ if v := g.Value(); 47 != v {
+ t.Errorf("g.Value(): 47 != %v\n", v)
+ }
+}
+
+func TestGaugeSnapshot(t *testing.T) {
+ g := NewGauge()
+ g.Update(int64(47))
+ snapshot := g.Snapshot()
+ g.Update(int64(0))
+ if v := snapshot.Value(); 47 != v {
+ t.Errorf("g.Value(): 47 != %v\n", v)
+ }
+}
+
+func TestGetOrRegisterGauge(t *testing.T) {
+ r := NewRegistry()
+ NewRegisteredGauge("foo", r).Update(47)
+ if g := GetOrRegisterGauge("foo", r); 47 != g.Value() {
+ t.Fatal(g)
+ }
+}