mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2024-06-08 00:42:25 +02:00
Add method "IsValidContinent".
This commit is contained in:
parent
2ac58a3360
commit
ffb79c747c
28
geoip.go
28
geoip.go
|
@ -239,3 +239,31 @@ func LookupContinents(country string) []string {
|
|||
return continents
|
||||
}
|
||||
}
|
||||
|
||||
func IsValidContinent(continent string) bool {
|
||||
switch continent {
|
||||
case "AF":
|
||||
// Africa
|
||||
fallthrough
|
||||
case "AN":
|
||||
// Antartica
|
||||
fallthrough
|
||||
case "AS":
|
||||
// Asia
|
||||
fallthrough
|
||||
case "EU":
|
||||
// Europe
|
||||
fallthrough
|
||||
case "NA":
|
||||
// North America
|
||||
fallthrough
|
||||
case "SA":
|
||||
// South America
|
||||
fallthrough
|
||||
case "OC":
|
||||
// Oceania
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -200,3 +200,13 @@ func TestGeoLookupFromFile(t *testing.T) {
|
|||
|
||||
testGeoLookupReader(t, reader)
|
||||
}
|
||||
|
||||
func TestIsValidContinent(t *testing.T) {
|
||||
for country, continents := range ContinentMap {
|
||||
for _, continent := range continents {
|
||||
if !IsValidContinent(continent) {
|
||||
t.Errorf("Continent %s of country %s is not valid", continent, country)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue