mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-09-18 22:25:41 +00:00
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package provider
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/sagernet/sing-box/option"
|
|
)
|
|
|
|
func TestFlagToCountryCodeAllFlags(t *testing.T) {
|
|
for first := 'A'; first <= 'Z'; first++ {
|
|
for second := 'A'; second <= 'Z'; second++ {
|
|
flag := string(rune(0x1F1E6+(first-'A'))) + string(rune(0x1F1E6+(second-'A')))
|
|
expected := string(first) + string(second)
|
|
result := flagToCountryCode(flag)
|
|
// flagToCountryCode appends a space
|
|
if result != expected+" " {
|
|
t.Errorf("flagToCountryCode(%q) = %q, want %q", expected, result, expected+" ")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestRemoveEmojisFromTags(t *testing.T) {
|
|
tests := []struct {
|
|
input string
|
|
expected string
|
|
}{
|
|
{"πΊπΈ United States", "US United States"},
|
|
{"π·πΊ Π ΠΎΡΡΠΈΡ", "RU Π ΠΎΡΡΠΈΡ"},
|
|
{"π©πͺ Germany π", "DE Germany"},
|
|
{"π«π·π¬π§ France-UK", "FR GB France-UK"},
|
|
{"No emojis here", "No emojis here"},
|
|
{"π World", "World"},
|
|
{"π―π΅ Tokyo β‘ Fast", "JP Tokyo Fast"},
|
|
{"Germany π©πͺ", "Germany DE"},
|
|
{"Server πΊπΈ Node", "Server US Node"},
|
|
}
|
|
for _, tt := range tests {
|
|
opts := []option.Outbound{{Tag: tt.input}}
|
|
removeEmojisFromTags(opts)
|
|
if opts[0].Tag != tt.expected {
|
|
t.Errorf("removeEmojisFromTags(%q) = %q, want %q", tt.input, opts[0].Tag, tt.expected)
|
|
}
|
|
}
|
|
}
|