package ch.unibe.scg.regex;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;

import org.junit.Before;
import org.junit.Test;

import ch.unibe.scg.regex.TDFATransitionTable.NextState;

@SuppressWarnings("javadoc")
public final class DFATableTest {
  static final int s1 = 0;
  static final int s2 = 1;
  static final int s3 = 2;
  static final int s4 = 3;
  TDFATransitionTable table;

  @Before
  public void setUp() {
    table =
        new TDFATransitionTable(new char[] {'c', 'l'}, new char[] {'k', 'm'}, new int[] {s1, s2},
            new int[] {s3, s4}, new Instruction[][] {new Instruction[] {}, new Instruction[] {}});
  }

  @Test
  public void testTable() {
    final NextState pr = table.newStateAndInstructions(200, 'd');
    assertThat(pr, is(nullValue()));
  }

  @Test
  public void testTable2() {
    final NextState pr = table.newStateAndInstructions(s1, 'c');
    assertThat(pr.nextState, is(s3));

  }

  @Test
  public void testTable3() {
    final NextState pr = table.newStateAndInstructions(s1, 'k');
    assertThat(pr.nextState, is(s3));

  }

  @Test
  public void testTable4() {
    final NextState pr = table.newStateAndInstructions(s1, 'l');
    assertThat(pr, is(nullValue()));

  }

  @Test
  public void testTable5() {
    final NextState pr = table.newStateAndInstructions(s2, 'l');
    assertThat(pr.nextState, is(s4));
  }

}

@@ -70,59 +70,8 @@
 is;%0A
-import static org.hamcrest.CoreMatchers.nullValue;%0A
 impo
@@ -416,16 +416,31 @@
 e table;
+%0A  NextState n;
 %0A%0A  @Bef
@@ -676,16 +676,41 @@
 %5D %7B%7D%7D);%0A
+    n = new NextState();%0A
   %7D%0A%0A  @
@@ -745,37 +745,16 @@
 () %7B%0A   
- final NextState pr =
  table.n
@@ -784,16 +784,19 @@
 200, 'd'
+, n
 );%0A    a
@@ -805,34 +805,41 @@
 ertThat(
-pr, is(nullValue()
+n.found, is(Boolean.FALSE
 ));%0A  %7D%0A
@@ -879,37 +879,16 @@
 () %7B%0A   
- final NextState pr =
  table.n
@@ -917,16 +917,19 @@
 (s1, 'c'
+, n
 );%0A    a
@@ -930,34 +930,76 @@
 %0A    assertThat(
-pr
+n.found, is(Boolean.TRUE));%0A    assertThat(n
 .nextState, is(s
@@ -995,33 +995,32 @@
 State, is(s3));%0A
-%0A
   %7D%0A%0A  @Test%0A  p
@@ -1048,37 +1048,16 @@
 () %7B%0A   
- final NextState pr =
  table.n
@@ -1086,16 +1086,19 @@
 (s1, 'k'
+, n
 );%0A    a
@@ -1099,34 +1099,76 @@
 %0A    assertThat(
-pr
+n.found, is(Boolean.TRUE));%0A    assertThat(n
 .nextState, is(s
@@ -1168,25 +1168,24 @@
 e, is(s3));%0A
-%0A
   %7D%0A%0A  @Test
@@ -1217,37 +1217,16 @@
 () %7B%0A   
- final NextState pr =
  table.n
@@ -1251,24 +1251,27 @@
 ions(s1, 'l'
+, n
 );%0A    asser
@@ -1280,31 +1280,37 @@
 hat(
-pr, is(nullValue()
+n.found, is(Boolean.FALSE
 ));%0A
-%0A
   %7D%0A
@@ -1354,29 +1354,8 @@
 %0A   
- final NextState pr =
  tab
@@ -1388,16 +1388,19 @@
 (s2, 'l'
+, n
 );%0A    a
@@ -1409,18 +1409,60 @@
 ertThat(
-pr
+n.found, is(Boolean.TRUE));%0A    assertThat(n
 .nextSta
@@ -1478,11 +1478,10 @@
 ));%0A  %7D%0A
-%0A
 %7D%0A

Modify DFATableTest to match optimization crap.