示例#1
0
文件: util_test.go 项目: Szewek/mcpm
func TestFileSize(t *testing.T) {
	cases := []testCaseFileSize{
		{2048, "2.00 kB"},
		{1024, "1.00 kB"},
		{64, "64 B"},
	}
	for i := 0; i < len(cases); i++ {
		result := util.FileSize(cases[i].input)
		if result != cases[i].wanted {
			t.Errorf("Expected %#v, got %#v!", cases[i].wanted, result)
		} else {
			t.Logf("Got %#v from %d", result, cases[i].input)
		}
	}
}
示例#2
0
文件: util_test.go 项目: Szewek/mcpm
func BenchmarkFileSize(b *testing.B) {
	for t := 0; t < b.N; t++ {
		util.FileSize(65536)
	}
}