ifTable_test.go 623 B

123456789101112131415161718192021222324
  1. package snmp
  2. import "testing"
  3. // #1280: un 2.5 GE reporta ifSpeed=2500000000; la división entera lo
  4. // truncaba a "2 Gbps". Los múltiplos exactos siguen sin decimales.
  5. func TestSpeedStringQuarterGigMultiples(t *testing.T) {
  6. cases := []struct {
  7. bps uint64
  8. want string
  9. }{
  10. {1_000_000_000, "1 Gbps"},
  11. {2_500_000_000, "2.5 Gbps"},
  12. {5_000_000_000, "5 Gbps"},
  13. {10_000_000_000, "10 Gbps"},
  14. {1_000_000, "1 Mbps"},
  15. }
  16. for _, c := range cases {
  17. p := PortStats{OperUp: true, SpeedBps: c.bps}
  18. if got := p.SpeedString(); got != c.want {
  19. t.Errorf("SpeedString(%d) = %q, want %q", c.bps, got, c.want)
  20. }
  21. }
  22. }