31 lines
613 B
Go
31 lines
613 B
Go
package fingerprint
|
|
|
|
import "testing"
|
|
|
|
func TestNetworkFingerPrint_linkspeed_parse(t *testing.T) {
|
|
f := &NetworkFingerprint{logger: testLogger(), interfaceDetector: &DefaultNetworkInterfaceDetector{}}
|
|
|
|
var outputTests = []struct {
|
|
in string
|
|
out int
|
|
}{
|
|
{"10 Mbps", 10},
|
|
{"2 bps", 0},
|
|
{"1 Gbps", 1000},
|
|
{"2Mbps", 0},
|
|
{"1000 Kbps", 1},
|
|
{"1 Kbps", 0},
|
|
{"0 Mbps", 0},
|
|
{"2 2 Mbps", 0},
|
|
{"a Mbps", 0},
|
|
{"1 Tbps", 0},
|
|
}
|
|
|
|
for _, ot := range outputTests {
|
|
out := f.parseLinkSpeed(ot.in)
|
|
if out != ot.out {
|
|
t.Errorf("parseLinkSpeed(%s) => %d, should be %d", ot.in, out, ot.out)
|
|
}
|
|
}
|
|
}
|