From e7715c9eaedc237104ddfb5a146636d5afab8d53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A4r=20Karlsson?= Date: Thu, 19 Oct 2017 13:17:07 +0200 Subject: [PATCH] Fixed the math tests. Added query.FindAllCountries() as requested in #15 --- math_test.go | 4 ++-- query.go | 5 +++++ query_test.go | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-) 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{}