Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

43 righe
1.0 KiB

  1. // Copyright 2018, OpenCensus Authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //
  15. package zpages
  16. import "testing"
  17. func TestCountFormatter(t *testing.T) {
  18. tests := []struct {
  19. in uint64
  20. want string
  21. }{
  22. {0, " "},
  23. {1, "1"},
  24. {1024, "1024"},
  25. {1e5, "100000"},
  26. {1e6, "1.000 M "},
  27. {1e9, "1.000 G "},
  28. {1e8 + 2e9, "2.100 G "},
  29. {1e12, "1.000 T "},
  30. {1e15, "1.000 P "},
  31. {1e18, "1.000 E "},
  32. }
  33. for _, tt := range tests {
  34. if g, w := countFormatter(tt.in), tt.want; g != w {
  35. t.Errorf("%d got %q want %q", tt.in, g, w)
  36. }
  37. }
  38. }