diff options
Diffstat (limited to 'internal/stats/debugstring_test.go')
| -rw-r--r-- | internal/stats/debugstring_test.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/internal/stats/debugstring_test.go b/internal/stats/debugstring_test.go new file mode 100644 index 0000000..88b2a5e --- /dev/null +++ b/internal/stats/debugstring_test.go @@ -0,0 +1,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 +} |
