Skip to content

Commit

Permalink
Fixed the math tests. Added query.FindAllCountries() as requested in #15
Browse files Browse the repository at this point in the history
  • Loading branch information
pariz committed Oct 19, 2017
1 parent a6cd508 commit e7715c9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions math_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package gountries

import "fmt"

func ExamplePythagorasEquirectangular() {
func ExampleCalculatePythagorasEquirectangular() {

se, _ := query.FindCountryByAlpha("SWE")
de, _ := query.FindCountryByAlpha("DEU")
Expand All @@ -22,7 +22,7 @@ func ExamplePythagorasEquirectangular() {
// 2667.2283097795016
}

func ExampleHaversine() {
func ExampleCalculateHaversine() {

se, _ := query.FindCountryByAlpha("SWE")
de, _ := query.FindCountryByAlpha("DEU")
Expand Down
5 changes: 5 additions & 0 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down
6 changes: 6 additions & 0 deletions query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down

0 comments on commit e7715c9

Please sign in to comment.