forked from schollz/find
-
Notifications
You must be signed in to change notification settings - Fork 0
/
network_test.go
26 lines (22 loc) · 1016 Bytes
/
network_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
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestBuildNetwork(t *testing.T) {
newNetwork := make(map[string]map[string]bool)
newNetwork = buildNetwork(newNetwork, []string{"pie", "ice cream"})
newNetwork = buildNetwork(newNetwork, []string{"pie", "cocolate syrup"})
newNetwork = buildNetwork(newNetwork, []string{"orange juice", "water"})
newNetwork = buildNetwork(newNetwork, []string{"water", "coffee"})
assert.Equal(t, newNetwork["0"], map[string]bool{"ice cream": true, "cocolate syrup": true, "pie": true})
}
func TestHasNetwork(t *testing.T) {
newNetwork := make(map[string]map[string]bool)
newNetwork = buildNetwork(newNetwork, []string{"pie", "ice cream"})
newNetwork = buildNetwork(newNetwork, []string{"pie", "cocolate syrup"})
newNetwork = buildNetwork(newNetwork, []string{"orange juice", "water"})
newNetwork = buildNetwork(newNetwork, []string{"water", "coffee"})
network, _ := hasNetwork(newNetwork, []string{"water"})
assert.Equal(t, network, "1")
}