mirror of
https://github.com/ap-pauloafonso/ratio-spoof.git
synced 2026-01-11 20:10:22 +00:00
31 lines
571 B
Go
31 lines
571 B
Go
package printer
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func TestHumanReadableSize(T *testing.T) {
|
|
data := []struct {
|
|
in float64
|
|
out string
|
|
}{
|
|
{1536, "1.50KiB"},
|
|
{379040563, "361.48MiB"},
|
|
{6291456, "6.00MiB"},
|
|
{372749107, "355.48MiB"},
|
|
{10485760, "10.00MiB"},
|
|
{15728640, "15.00MiB"},
|
|
{363311923, "346.48MiB"},
|
|
{16777216, "16.00MiB"},
|
|
{379040563, "361.48MiB"},
|
|
}
|
|
for idx, td := range data {
|
|
T.Run(fmt.Sprint(idx), func(t *testing.T) {
|
|
got := humanReadableSize(td.in)
|
|
if got != td.out {
|
|
t.Errorf("got %q, want %q", got, td.out)
|
|
}
|
|
})
|
|
}
|
|
}
|