25 lines
605 B
Go
25 lines
605 B
Go
|
|
package bcap
|
||
|
|
|
||
|
|
import (
|
||
|
|
"testing"
|
||
|
|
"time"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestFormatHelpers(t *testing.T) {
|
||
|
|
if got := FormatDuration(500 * time.Nanosecond); got != "500ns" {
|
||
|
|
t.Fatalf("FormatDuration(ns) = %q", got)
|
||
|
|
}
|
||
|
|
if got := FormatDuration(1500 * time.Microsecond); got != "1.50ms" {
|
||
|
|
t.Fatalf("FormatDuration(ms) = %q", got)
|
||
|
|
}
|
||
|
|
if got := FormatDuration(2 * time.Second); got != "2.00s" {
|
||
|
|
t.Fatalf("FormatDuration(s) = %q", got)
|
||
|
|
}
|
||
|
|
if got := FormatBytes(512); got != "512 B" {
|
||
|
|
t.Fatalf("FormatBytes(bytes) = %q", got)
|
||
|
|
}
|
||
|
|
if got := FormatBytes(1536); got != "1.50 KB" {
|
||
|
|
t.Fatalf("FormatBytes(kb) = %q", got)
|
||
|
|
}
|
||
|
|
}
|