MCPcopy
hub / github.com/github/git-sizer / TestBinary

Function TestBinary

counts/human_test.go:73–110  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

71}
72
73func TestBinary(t *testing.T) {
74 assert := assert.New(t)
75
76 for _, ht := range []humanTest{
77 {0, "0", "B"},
78 {1, "1", "B"},
79 {1023, "1023", "B"},
80 {1024, "1.00", "KiB"},
81 {1234, "1.21", "KiB"},
82 {1048575, "1024", "KiB"}, // Not ideal, but ok
83 {1048576, "1.00", "MiB"},
84 {1073741823, "1024", "MiB"}, // Not ideal, but ok
85 {1073741824, "1.00", "GiB"},
86 {1099511627775, "1024", "GiB"}, // Not ideal, but ok
87 {1099511627776, "1.00", "TiB"},
88 {1125899906842623, "1024", "TiB"}, // Not ideal, but ok
89 {1125899906842624, "1.00", "PiB"},
90 {1152921504606846975, "1024", "PiB"},
91 {1152921504606846976, "1024", "PiB"},
92 {0xffffffffffffffff, "16384", "PiB"},
93 } {
94 number, unit := counts.Binary.FormatNumber(ht.n, "B")
95 assert.Equalf(ht.number, number, "Number for %d in binary", ht.n)
96 assert.Equalf(ht.unit, unit, "Unit for %d in binary", ht.n)
97 if ht.n < 0xffffffff {
98 c := counts.NewCount32(ht.n)
99 number, unit := counts.Binary.Format(c, "B")
100 assert.Equalf(ht.number, number, "Number for Count32(%d) in binary", ht.n)
101 assert.Equalf(ht.unit, unit, "Unit for Count32(%d) in binary", ht.n)
102 }
103 if ht.n < 0xffffffffffffffff {
104 c := counts.NewCount64(ht.n)
105 number, unit := counts.Binary.Format(c, "B")
106 assert.Equalf(ht.number, number, "Number for Count64(%d) in binary", ht.n)
107 assert.Equalf(ht.unit, unit, "Unit for Count64(%d) in binary", ht.n)
108 }
109 }
110}
111
112func TestLimits32(t *testing.T) {
113 assert := assert.New(t)

Callers

nothing calls this directly

Calls 4

NewCount32Function · 0.92
NewCount64Function · 0.92
FormatNumberMethod · 0.80
FormatMethod · 0.80

Tested by

no test coverage detected