package member

import "testing"

func TestPlatform_ToInt64(t *testing.T) {
	tests := []struct {
		platform Platform
		expected int64
	}{
		{Digimon, 1},
		{Google, 2},
		{Line, 3},
		{Apple, 4},
		{PlatformNone, -1},
	}

	for _, tt := range tests {
		t.Run(tt.platform.ToString(), func(t *testing.T) {
			if result := tt.platform.ToInt64(); result != tt.expected {
				t.Errorf("ToInt64() = %v, want %v", result, tt.expected)
			}
		})
	}
}

func TestPlatform_ToString(t *testing.T) {
	tests := []struct {
		platform Platform
		expected string
	}{
		{Digimon, DigimonString},
		{Google, GoogleString},
		{Line, LineString},
		{Apple, AppleString},
		{PlatformNone, ""},
	}

	for _, tt := range tests {
		t.Run(tt.expected, func(t *testing.T) {
			if result := tt.platform.ToString(); result != tt.expected {
				t.Errorf("ToString() = %v, want %v", result, tt.expected)
			}
		})
	}
}

func TestGetPlatformByPlatformCode(t *testing.T) {
	tests := []struct {
		code     string
		expected Platform
	}{
		{DigimonString, Digimon},
		{GoogleString, Google},
		{LineString, Line},
		{AppleString, Apple},
		{"unknown", PlatformNone}, // 測試不存在的 Platform
	}

	for _, tt := range tests {
		t.Run(tt.code, func(t *testing.T) {
			if result := GetPlatformByPlatformCode(tt.code); result != tt.expected {
				t.Errorf("GetPlatformByPlatformCode(%v) = %v, want %v", tt.code, result, tt.expected)
			}
		})
	}
}
