diff --git a/math_test.go b/math_test.go index 61d8026..2059c06 100644 --- a/math_test.go +++ b/math_test.go @@ -2,7 +2,7 @@ package gountries import "fmt" -func ExamplePythagorasEquirectangular() { +func ExampleCalculatePythagorasEquirectangular() { se, _ := query.FindCountryByAlpha("SWE") de, _ := query.FindCountryByAlpha("DEU") @@ -22,7 +22,7 @@ func ExamplePythagorasEquirectangular() { // 2667.2283097795016 } -func ExampleHaversine() { +func ExampleCalculateHaversine() { se, _ := query.FindCountryByAlpha("SWE") de, _ := query.FindCountryByAlpha("DEU") diff --git a/query.go b/query.go index ee4b4df..45ab769 100644 --- a/query.go +++ b/query.go @@ -47,6 +47,11 @@ func (q *Query) FindCountryByAlpha(code string) (result Country, err error) { } } +// FindAllCountries returns a list of all countries +func (q *Query) FindAllCountries() (countries map[string]Country) { + return q.Countries +} + // FindCountries finds a Country based on the given struct data func (q Query) FindCountries(c Country) (countries []Country) { diff --git a/query_test.go b/query_test.go index 9860ed1..94a75c5 100644 --- a/query_test.go +++ b/query_test.go @@ -149,6 +149,12 @@ func TestFindCountryByAlpha(t *testing.T) { } +func TestFindAllCountries(t *testing.T) { + + assert.Len(t, query.FindAllCountries(), 247) + +} + func TestFindCountries(t *testing.T) { country := Country{}