-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch_test.go
36 lines (33 loc) · 965 Bytes
/
fetch_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
package main
import (
"reflect"
"strings"
"testing"
)
func TestMergeMultipleSources(t *testing.T) {
var tests = []struct {
source1 Spells
source2 Spells
want Spells
}{
{ExampleSpells[:2], ExampleSpells[2:], ExampleSpells},
{ExampleSpells[2:], ExampleSpells[:2], ExampleSpells},
{Spells{ExampleSpells[0], ExampleSpells[2]}, Spells{ExampleSpells[1], ExampleSpells[3]}, ExampleSpells},
{Spells{ExampleSpells[0], ExampleSpells[3]}, Spells{ExampleSpells[1], ExampleSpells[2]}, ExampleSpells},
}
for _, test := range tests {
//t.Log(test.source1)
//t.Log(test.source2)
output := mergeMultipleSources(&test.source1, &test.source2)
if !reflect.DeepEqual(*output, test.want) {
var o, w []string
for _, v := range *output {
o = append(o, v.Index)
}
for _, v := range test.want {
w = append(w, v.Index)
}
t.Errorf("Unexpected result.\nhave:\"%v\"\nwant:\"%v\"", strings.Join(o, ","), strings.Join(w, ","))
}
}
}