-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwingspan_test.go
73 lines (66 loc) · 3.03 KB
/
wingspan_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package bird_data_guessing
import (
"testing"
"github.com/gbdubs/inference"
)
func TestWingspan_Wikipedia(t *testing.T) {
wikipediaWingspan := func(latinName string) []*inference.Float64Range {
return wikipediaRequestForTesting(latinName).propertySearchers().wingspan.Wingspan()
}
testSliceRangeFloat64Cases(t, wikipediaWingspan,
unorderedSliceRangeFloat64Case("Aythya valisineria", 79.0, 89.0),
unorderedSliceRangeFloat64Case("Cistothorus palustris", 15, 15),
unorderedSliceRangeFloat64Case("Passer domesticus", 19.0, 25),
unorderedSliceRangeFloat64Case("Pooecetes gramineus", 24, 24),
unorderedSliceRangeFloat64Case("Loxia leucoptera", 26, 29),
unorderedSliceRangeFloat64Case("Columba livia", 62, 72),
unorderedSliceRangeFloat64Case("Riparia riparia", 25, 33),
unorderedSliceRangeFloat64Case("Spinus pinus", 18, 22),
unorderedSliceRangeFloat64Case("Junco hyemalis", 18, 25),
unorderedSliceRangeFloat64Case("Ictinia mississippiensis", 91, 91, 91.44, 91.44),
unorderedSliceRangeFloat64Case("Bubulcus ibis", 88, 96),
unorderedSliceRangeFloat64Case("Spizella pallida", 19, 19),
unorderedSliceRangeFloat64Case("Euphagus cyanocephalus", 39, 39),
unorderedSliceRangeFloat64Case("Melanitta americana", 71, 71),
unorderedSliceRangeFloat64Case("Accipiter striatus", 58, 68, 42, 58),
)
}
func TestWingspan_WhatBird(t *testing.T) {
whatBirdWingspan := func(englishName string) []*inference.Float64Range {
return whatBirdRequestForTesting(englishName).propertySearchers().wingspan.Wingspan()
}
testSliceRangeFloat64Cases(t, whatBirdWingspan,
unorderedSliceRangeFloat64Case("Black-backed Woodpecker", 43.0, 43.0),
unorderedSliceRangeFloat64Case("Allen's Hummingbird", 12.0, 12.0),
unorderedSliceRangeFloat64Case("Turkey vulture", 173.0, 183.0),
unorderedSliceRangeFloat64Case("Bald eagle", 183.0, 244.0),
unorderedSliceRangeFloat64Case("Striped Owl", 76.0, 97.0),
)
}
func TestWingspan_AllAboutBirds(t *testing.T) {
whatBirdWingspan := func(englishName string) []*inference.Float64Range {
return allAboutBirdsRequestForTesting(englishName).propertySearchers().wingspan.Wingspan()
}
testSliceRangeFloat64Cases(t, whatBirdWingspan,
unorderedSliceRangeFloat64Case("Sprague's Pipit"),
unorderedSliceRangeFloat64Case("Bald eagle", 204, 204),
unorderedSliceRangeFloat64Case("Brandt's cormorant", 108, 108),
)
}
func TestWingspan_RSPB(t *testing.T) {
rspbWingspan := func(englishName string) []*inference.Float64Range {
return rspbRequestForTesting(englishName).propertySearchers().wingspan.Wingspan()
}
testSliceRangeFloat64Cases(t, rspbWingspan,
unorderedSliceRangeFloat64Case("Stonechat", 18, 21),
unorderedSliceRangeFloat64Case("Temminck's Stint", 34, 37),
unorderedSliceRangeFloat64Case("Stone curlew", 77, 85),
)
}
// Audubon does not have reliable wingspan information.
func TestWingspan_Audubon_NoContentInSearcher(t *testing.T) {
searcherText := audubonRequestForTesting("Bald eagle").propertySearchers().wingspan.text
if searcherText != "" {
t.Errorf("Expected Audubon Wingspan to be empty, but was %s.", searcherText)
}
}