1 17 18 package org.sablecc.sablecc.automaton; 19 20 import static org.junit.Assert.fail; 21 22 import java.util.SortedSet ; 23 24 import org.junit.Before; 25 import org.junit.Test; 26 import org.sablecc.sablecc.exception.InternalException; 27 28 public class StateMatcherTest { 29 30 StateMatcher<Integer > stateMatcher; 31 32 Dfa<Integer > dfa; 33 34 Nfa<Integer > nfa; 35 36 @Before 37 public void setUp() 38 throws Exception { 39 40 this.nfa = new Nfa<Integer >(); 41 42 this.dfa = new Dfa<Integer >(this.nfa); 43 44 this.stateMatcher = new StateMatcher<Integer >(this.dfa, this.nfa); 45 } 46 47 @Test 48 public void testStateMatcher() { 49 50 Dfa<Integer > nullDfa = null; 52 try { 53 this.stateMatcher = new StateMatcher<Integer >(nullDfa, this.nfa); 54 fail("dfa may not be null"); 55 } 56 catch (InternalException e) { 57 } 59 Nfa<Integer > nullNfa = null; 61 try { 62 this.stateMatcher = new StateMatcher<Integer >(this.dfa, nullNfa); 63 fail("nfa may not be null"); 64 } 65 catch (InternalException e) { 66 } 68 } 69 70 @Test 71 public void testGetDfaState() { 72 73 SortedSet <NfaState<Integer >> nfaStates = null; 75 try { 76 this.stateMatcher.getDfaState(nfaStates); 77 fail("nfaStates may not be null"); 78 } 79 catch (InternalException e) { 80 } 82 83 } 84 85 @Test 86 public void testGetNfaStates() { 87 88 DfaState<Integer > nullState = null; 90 try { 91 this.stateMatcher.getNfaStates(nullState); 92 fail("dfaState may not be null"); 93 } 94 catch (InternalException e) { 95 } 97 98 } 99 100 @Test 101 public void testMatch() { 102 103 DfaState<Integer > nullDfaState = null; 105 try { 106 this.stateMatcher.match(nullDfaState, this.nfa.getAcceptState()); 107 fail("dfaState may not be null"); 108 } 109 catch (InternalException e) { 110 } 112 113 NfaState<Integer > nullNfaState = null; 115 try { 116 this.stateMatcher.match(this.dfa.getStartState(), nullNfaState); 117 fail("nfaState may not be null"); 118 } 119 catch (InternalException e) { 120 } 122 } 123 124 } 125 | Popular Tags |