Skip to content

Commit 1ecbf63

Browse files
committed
Nuevo test y faltaba cambiar el package del archivo de test de las estructuras
1 parent 6cbd518 commit 1ecbf63

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

dfa_estructures_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// +build estructures all
22

3-
package DFA
3+
package dfa
44

55
import testing "testing"
66

dfa_test.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,62 @@ func Test4DFANoMinimo(t *testing.T) {
194194
t.Errorf("error, expected 1 final state got %d", Min.FinalStates.Size())
195195
}
196196
}
197+
198+
func Test5DFAMinimo(t *testing.T) {
199+
var states []State
200+
A := 0
201+
B := 1
202+
C := 2
203+
D := 3
204+
E := 4
205+
F := 5
206+
states = append(states, A, B, C, D, E, F)
207+
fs := []State{A , B, C, D, F}
208+
alphabet := []int{0, 1}
209+
delta := make(map[State]map[int]State)
210+
delta[A] = map[int]State{0: B, 1: E}
211+
delta[B] = map[int]State{0: B, 1: C}
212+
delta[C] = map[int]State{0: D, 1: E}
213+
delta[D] = map[int]State{0: F, 1: C}
214+
delta[E] = map[int]State{0: E, 1: E}
215+
delta[F] = map[int]State{0: F, 1: E}
216+
217+
M := DFA{States: states, InitialState: A, FinalStates: fs, Delta: delta, Alphabet: alphabet}
218+
219+
Min := HopcroftDFAMin(M)
220+
221+
if Min.States.Size() > M.States.Size() {
222+
t.Errorf("error, minimized automata should have the same number of states, got %d", Min.States.Size())
223+
}
224+
225+
}
226+
227+
func Test6DFAMinimo(t *testing.T) {
228+
// L = (11111)+
229+
var states []State
230+
A := 0
231+
B := 1
232+
C := 2
233+
D := 3
234+
E := 4
235+
F := 5
236+
states = append(states, A, B, C, D, E, F)
237+
fs := []State{ F }
238+
alphabet := []int{0, 1}
239+
delta := make(map[State]map[int]State)
240+
delta[A] = map[int]State{1: B}
241+
delta[B] = map[int]State{1: C}
242+
delta[C] = map[int]State{1: D}
243+
delta[D] = map[int]State{1: E}
244+
delta[E] = map[int]State{1: F}
245+
delta[F] = map[int]State{1: A}
246+
247+
M := DFA{States: states, InitialState: A, FinalStates: fs, Delta: delta, Alphabet: alphabet}
248+
249+
Min := HopcroftDFAMin(M)
250+
251+
if Min.States.Size() != M.States.Size() {
252+
t.Errorf("error, minimized automata should have the same number of states, got %d", Min.States.Size())
253+
}
254+
255+
}

0 commit comments

Comments
 (0)