blob: 88b2a5e483a4a9998bcf18803582fd22a96fcb80 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
package stats
import "testing"
func TestSnapshotDebugString(t *testing.T) {
s := Snapshot{}
s.Global.Reqs = 42
s.RPM = 3.14
got := s.DebugString()
if got == "" || !contains(got, "Σ reqs=42") || !contains(got, "rpm=") {
t.Fatalf("unexpected debug string: %q", got)
}
}
func contains(s, sub string) bool {
for i := 0; i+len(sub) <= len(s); i++ {
if s[i:i+len(sub)] == sub {
return true
}
}
return false
}
|