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)
	}
}
