1 17 18 package org.sablecc.sablecc.automaton; 19 20 import static org.junit.Assert.assertEquals; 21 import static org.junit.Assert.assertTrue; 22 import static org.junit.Assert.fail; 23 24 import org.junit.Before; 25 import org.junit.Test; 26 import org.sablecc.sablecc.exception.InternalException; 27 28 public class DfaTest { 29 30 Dfa<Integer > dfa; 31 32 Nfa<Integer > nfa; 33 34 @Before 35 public void setUp() 36 throws Exception { 37 38 this.nfa = new Nfa<Integer >(); 39 this.dfa = new Dfa<Integer >(this.nfa); 40 } 41 42 @SuppressWarnings ("unused") 43 @Test 44 public void testDfa() { 45 46 Nfa<Integer > nullNfa = null; 48 49 try { 50 Dfa<Integer > dfa = new Dfa<Integer >(nullNfa); 51 } 52 catch (InternalException e) { 53 } 55 56 assertTrue("the startState should be an acceptationState", this.dfa 58 .getAcceptStates().first() == this.dfa.getStartState()); 59 assertEquals("there should only be one acceptationState", 1, this.dfa 60 .getAcceptStates().size()); 61 } 62 63 @Test 64 public void testShortest() { 65 66 Nfa<Integer > nullNfa = null; 68 69 try { 70 this.dfa = Dfa.shortest(nullNfa); 71 fail("nfa may not be null"); 72 } 73 catch (InternalException e) { 74 } 76 77 } 78 79 @Test 80 public void testDifference() { 81 82 Nfa<Integer > nullNfa = null; 84 85 try { 86 this.dfa = Dfa.difference(nullNfa, this.nfa); 87 fail("this Nfa may not be null"); 88 } 89 catch (InternalException e) { 90 } 92 93 try { 94 this.dfa = Dfa.difference(this.nfa, nullNfa); 95 fail("nfa may not be null"); 96 } 97 catch (InternalException e) { 98 } 100 101 } 102 103 @Test 104 public void testIntersection() { 105 106 Nfa<Integer > nullNfa = null; 108 109 try { 110 this.dfa = Dfa.intersection(nullNfa, this.nfa); 111 fail("this Nfa may not be null"); 112 } 113 catch (InternalException e) { 114 } 116 117 try { 118 this.dfa = Dfa.intersection(this.nfa, nullNfa); 119 fail("nfa may not be null"); 120 } 121 catch (InternalException e) { 122 } 124 125 } 126 } 127 | Popular Tags |