-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallback_test.go
More file actions
29 lines (25 loc) · 1.04 KB
/
callback_test.go
File metadata and controls
29 lines (25 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package main
import "testing"
func TestFormatCompressionStats(t *testing.T) {
t.Run("includes compression ratio", func(t *testing.T) {
got := formatCompressionStats("capture.pcap", "capture.pcap.bz2", 1024, 256)
want := "capture.pcap -> capture.pcap.bz2 (1024 bytes -> 256 bytes, ratio 4.00:1)"
if got != want {
t.Fatalf("formatCompressionStats() = %q, want %q", got, want)
}
})
t.Run("handles zero compressed size", func(t *testing.T) {
got := formatCompressionStats("capture.pcap", "capture.pcap.bz2", 1024, 0)
want := "capture.pcap -> capture.pcap.bz2 (1024 bytes -> 0 bytes, ratio unavailable: empty compressed file)"
if got != want {
t.Fatalf("formatCompressionStats() = %q, want %q", got, want)
}
})
t.Run("handles zero original size", func(t *testing.T) {
got := formatCompressionStats("capture.pcap", "capture.pcap.bz2", 0, 128)
want := "capture.pcap -> capture.pcap.bz2 (0 bytes -> 128 bytes, ratio unavailable: empty input file)"
if got != want {
t.Fatalf("formatCompressionStats() = %q, want %q", got, want)
}
})
}