-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdfa_estructures_test.go
94 lines (77 loc) · 1.39 KB
/
dfa_estructures_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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// +build estructures all
package dfa
import testing "testing"
func TestPartitionNotEmpty(t *testing.T) {
q0 := 0
partition := Partition{q0}
if partition.IsEmpty() {
t.Error()
}
}
func TestPartitionEmpty(t *testing.T) {
partition := Partition{}
if !partition.IsEmpty() {
t.Error()
}
q0 := 0
partition.Add(q0)
if partition.IsEmpty() {
t.Error()
}
}
func TestPartitionExtractElem(t *testing.T) {
q0 := 0
partition := Partition{q0}
partition.ExtractElem(q0)
if !partition.IsEmpty() {
t.Error()
}
q1 := 1
partition.Add(q0)
partition.Add(q1)
partition.ExtractElem(q1)
if !partition.Includes(q0) {
t.Error()
}
if partition.Includes(q1) {
t.Error()
}
}
func TestPartitionExtractPartitionWithNoIntersection(t *testing.T) {
q1 := 1
q2 := 2
q3 := 3
q4 := 4
p1 := Partition{q1, q2}
p2 := Partition{q3, q4}
oldSizeSum := p1.Size() + p2.Size()
p1.Extract(p2)
if oldSizeSum != p1.Size()+p2.Size() {
t.Error()
}
}
func TestPartitionExtractPartitionWithIntersection(t *testing.T) {
q1 := 1
q2 := 2
q3 := 3
q4 := 4
p1 := Partition{q1, q2, q4}
p2 := Partition{q3, q4}
oldSizeP1 := p1.Size()
p1.Extract(p2)
if oldSizeP1 != p1.Size()+1 {
t.Error()
}
}
func TestPartitionExtractPartitionBiggerBecomesEmpty(t *testing.T) {
q1 := 1
q2 := 2
q3 := 3
q4 := 4
p1 := Partition{q1, q2, q3, q4}
p2 := Partition{q3, q4}
p2.Extract(p1)
if !p2.IsEmpty() {
t.Error()
}
}