goProject/trunk/goutil/deviceUtil/deviceUtil_test.go
皮蛋13361098506 1b77f62820 初始化项目
2025-01-06 16:01:02 +08:00

132 lines
3.1 KiB
Go

package deviceUtil
import (
"testing"
)
func TestConvertMacToStarndardFormat(t *testing.T) {
mac := ""
expected := ""
got := ConvertMacToStandardFormat(mac)
if got != expected {
t.Errorf("Expected: %s, but got:%s", expected, got)
}
mac = "00:00:00:00:00:00"
expected = ""
got = ConvertMacToStandardFormat(mac)
if got != expected {
t.Errorf("Expected: %s, but got:%s", expected, got)
}
mac = "02:00:00:00:00:00"
expected = ""
got = ConvertMacToStandardFormat(mac)
if got != expected {
t.Errorf("Expected: %s, but got:%s", expected, got)
}
mac = "02:00:00:00:00"
expected = ""
got = ConvertMacToStandardFormat(mac)
if got != expected {
t.Errorf("Expected: %s, but got:%s", expected, got)
}
mac = "020000000020"
expected = "02:00:00:00:00:20"
got = ConvertMacToStandardFormat(mac)
if got != expected {
t.Errorf("Expected: %s, but got:%s", expected, got)
}
mac = "02:00:00:00:00:20"
expected = "02:00:00:00:00:20"
got = ConvertMacToStandardFormat(mac)
if got != expected {
t.Errorf("Expected: %s, but got:%s", expected, got)
}
}
func TestConvertIdfaToStandardFormat(t *testing.T) {
idfa := ""
expected := ""
got := ConvertIdfaToStandardFormat(idfa)
if got != expected {
t.Errorf("Expected: %s, but got:%s", expected, got)
}
idfa = "00000000-0000-0000-0000-000000000000"
expected = ""
got = ConvertIdfaToStandardFormat(idfa)
if got != expected {
t.Errorf("Expected: %s, but got:%s", expected, got)
}
idfa = "00000000-0000-0000-0000-000000000000-123"
expected = "00000000-0000-0000-0000-000000000000-123"
got = ConvertIdfaToStandardFormat(idfa)
if got != expected {
t.Errorf("Expected: %s, but got:%s", expected, got)
}
idfa = "00000000-1234-5678-0000-000000000000"
expected = "00000000-1234-5678-0000-000000000000"
got = ConvertIdfaToStandardFormat(idfa)
if got != expected {
t.Errorf("Expected: %s, but got:%s", expected, got)
}
idfa = "00000000123456780000000000000000"
expected = "00000000-1234-5678-0000-000000000000"
got = ConvertIdfaToStandardFormat(idfa)
if got != expected {
t.Errorf("Expected: %s, but got:%s", expected, got)
}
}
func TestGetIdentifier(t *testing.T) {
mac := ""
idfa := ""
expected := ""
got := GetIdentifier(mac, idfa)
if got != expected {
t.Errorf("Expected: %s, but got:%s", expected, got)
}
mac = "00:00:00:00:00:00"
expected = ""
got = GetIdentifier(mac, idfa)
if got != expected {
t.Errorf("Expected: %s, but got:%s", expected, got)
}
mac = "02:00:00:00:00:00"
expected = ""
got = GetIdentifier(mac, idfa)
if got != expected {
t.Errorf("Expected: %s, but got:%s", expected, got)
}
mac = "020000000020"
expected = "02:00:00:00:00:20"
got = GetIdentifier(mac, idfa)
if got != expected {
t.Errorf("Expected: %s, but got:%s", expected, got)
}
mac = "02:00:00:00:00:20"
expected = "02:00:00:00:00:20"
got = GetIdentifier(mac, idfa)
if got != expected {
t.Errorf("Expected: %s, but got:%s", expected, got)
}
idfa = "00000000123456780000000000000000"
expected = "00000000-1234-5678-0000-000000000000"
got = GetIdentifier(mac, idfa)
if got != expected {
t.Errorf("Expected: %s, but got:%s", expected, got)
}
}