| 222 | } |
| 223 | |
| 224 | func TestFormatBytesUnit(t *testing.T) { |
| 225 | for desc, c := range map[string]*FormatBytesUnitTestCase{ |
| 226 | "format bytes": {uint64(1 * math.Pow(10, 0)), humanize.Byte, "1"}, |
| 227 | "format kilobytes": {uint64(1 * math.Pow(10, 3)), humanize.Byte, "1000"}, |
| 228 | "format megabytes": {uint64(1 * math.Pow(10, 6)), humanize.Byte, "1000000"}, |
| 229 | "format gigabytes": {uint64(1 * math.Pow(10, 9)), humanize.Byte, "1000000000"}, |
| 230 | "format petabytes": {uint64(1 * math.Pow(10, 12)), humanize.Byte, "1000000000000"}, |
| 231 | "format terabytes": {uint64(1 * math.Pow(10, 15)), humanize.Byte, "1000000000000000"}, |
| 232 | |
| 233 | "format kilobytes under": {uint64(1.49 * math.Pow(10, 3)), humanize.Byte, "1490"}, |
| 234 | "format megabytes under": {uint64(1.49 * math.Pow(10, 6)), humanize.Byte, "1490000"}, |
| 235 | "format gigabytes under": {uint64(1.49 * math.Pow(10, 9)), humanize.Byte, "1490000000"}, |
| 236 | "format petabytes under": {uint64(1.49 * math.Pow(10, 12)), humanize.Byte, "1490000000000"}, |
| 237 | "format terabytes under": {uint64(1.49 * math.Pow(10, 15)), humanize.Byte, "1490000000000000"}, |
| 238 | |
| 239 | "format kilobytes over": {uint64(1.51 * math.Pow(10, 3)), humanize.Byte, "1510"}, |
| 240 | "format megabytes over": {uint64(1.51 * math.Pow(10, 6)), humanize.Byte, "1510000"}, |
| 241 | "format gigabytes over": {uint64(1.51 * math.Pow(10, 9)), humanize.Byte, "1510000000"}, |
| 242 | "format petabytes over": {uint64(1.51 * math.Pow(10, 12)), humanize.Byte, "1510000000000"}, |
| 243 | "format terabytes over": {uint64(1.51 * math.Pow(10, 15)), humanize.Byte, "1510000000000000"}, |
| 244 | } { |
| 245 | t.Run(desc, c.Assert) |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | func TestFormateByteRate(t *testing.T) { |
| 250 | for desc, c := range map[string]*FormatByteRateTestCase{ |