-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
43 lines (35 loc) · 1.02 KB
/
main_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
package main
import (
"testing"
"github.com/andey-robins/magical/graph"
"github.com/andey-robins/magical/sequence"
)
func TestIsValidSequence(t *testing.T) {
tests := []struct {
graphString string
sequenceString string
expectedValidity bool
maxMemoryUtil int
}{
{
"Inputs 3\n1 2 3\nOutputs 1\n4\nNodes 4\nEdges 6\n1 5\n2 7\n3 6\n5 7\n6 4\n7 4",
"Operations 4\n5\n6\n7\n4",
true,
4,
},
}
for _, test := range tests {
g := graph.LoadGraphFromString(test.graphString)
s := sequence.LoadSequenceFromString(test.sequenceString)
if g.IsValidSequence(s) != test.expectedValidity {
t.Errorf("Sequence validity check failed. Expected %t, got %t", test.expectedValidity, g.IsValidSequence(s))
}
mem, err := g.SimulateSequence(s)
if err != nil {
t.Errorf("Sequence simulation failed. Got error: %s", err)
}
if mem.GetMaxUtilization() != test.maxMemoryUtil {
t.Errorf("Max memory utilization check failed. Expected %d, got %d", test.maxMemoryUtil, mem.GetMaxUtilization())
}
}
}