import static org.junit.Assert.assertEquals;

import org.junit.Test;
import swf.measure.timeseries.dynamictimewarping.SakoeChibaBand;

public class SakoeChibaBandTest {
  @Test
  public void testIsConditionFulfilledEvenWidth() {
    SakoeChibaBand scb = new SakoeChibaBand(0.3);
    boolean[][] conditionMatrix = this.createConditionMatrix10x8window3();
    for (int i = 0; i < conditionMatrix.length; i++) {
      for (int j = 0; j < conditionMatrix[i].length; j++) {
        assertEquals(conditionMatrix[i][j], scb.isConditionFulfilled(i, j, 10, 8));
      }
    }
  }

  @Test
  public void testIsConditionFulfilledOddWidth() {
    SakoeChibaBand scb = new SakoeChibaBand(0.2);
    boolean[][] conditionMatrix = this.createConditionMatrix4x7window3();
    for (int i = 0; i < conditionMatrix.length; i++) {
      for (int j = 0; j < conditionMatrix[i].length; j++) {
        assertEquals(conditionMatrix[i][j], scb.isConditionFulfilled(i, j, 4, 7));
      }
    }
  }

  private boolean[][] createConditionMatrix10x8window3() {
    boolean[][] conditionMatrix = {
        {true, true, false, false, false, false, false, false},
        {true, true, true, false, false, false, false, false},
        {true, true, true, true, false, false, false, false},
        {false, true, true, true, true, false, false, false},
        {false, false, true, true, true, true, false, false},
        {false, false, true, true, true, true, false, false},
        {false, false, false, true, true, true, true, false},
        {false, false, false, false, true, true, true, true},
        {false, false, false, false, false, true, true, true},
        {false, false, false, false, false, false, true, true}
    };
    return conditionMatrix;
  }

  private boolean[][] createConditionMatrix4x7window3() {
    boolean[][] conditionMatrix = {
        {true, true, true, true, false, false, false},
        {true, true, true, true, true, true, false},
        {false, true, true, true, true, true, true},
        {false, false, false, true, true, true, true}
    };
    return conditionMatrix;
  }
}

@@ -272,33 +272,30 @@
 d(0.3);%0A    
-boolean%5B%5D
+String
 %5B%5D condition
@@ -442,32 +442,34 @@
 Matrix%5Bi%5D.length
+()
 ; j++) %7B%0A       
@@ -482,38 +482,97 @@
 tEquals(
-conditionMatrix%5Bi%5D%5Bj%5D,
+%0A            stringToBoolean(conditionMatrix%5Bi%5D.substring(j, j + 1)),%0A           
  scb.isC
@@ -601,16 +601,25 @@
 , 10, 8)
+%0A        
 );%0A     
@@ -741,33 +741,30 @@
 d(0.2);%0A    
-boolean%5B%5D
+String
 %5B%5D condition
@@ -918,16 +918,18 @@
 %5D.length
+()
 ; j++) %7B
@@ -954,30 +954,89 @@
 als(
-conditionMatrix%5Bi%5D%5Bj%5D,
+%0A            stringToBoolean(conditionMatrix%5Bi%5D.substring(j, j + 1)),%0A           
  scb
@@ -1068,16 +1068,25 @@
 j, 4, 7)
+%0A        
 );%0A     
@@ -1120,710 +1120,401 @@
 lean
-%5B%5D%5B%5D createConditionMatrix10x8window3() %7B%0A    boolean%5B%5D%5B%5D conditionMatrix = %7B%0A        %7Btrue, true, false, false, false, false, false, false%7D,%0A        %7Btrue, true, true, false, false, false, false, false%7D,%0A        %7Btrue, true, true, true, false, false, false, false%7D,%0A        %7Bfalse, true, true, true, true, false, false, false%7D,%0A        %7Bfalse, false, true, true, true, true, false, false%7D,%0A        %7Bfalse, false, true, true, true, true, false, false%7D,%0A        %7Bfalse, false, false, true, true, true, true, false%7D,%0A        %7Bfalse, false, false, false, true, true, true, true%7D,%0A        %7Bfalse, false, false, false, false, true, true, true%7D,%0A        %7Bfalse, false, false, false, false, false, true, true%7D
+ stringToBoolean(String str) %7B%0A    if (str.equals(%220%22)) %7B%0A      return false;%0A    %7D%0A    return true;%0A  %7D%0A%0A  private String%5B%5D createConditionMatrix10x8window3() %7B%0A    String%5B%5D conditionMatrix = %7B%0A        %2211000000%22,%0A        %2211100000%22,%0A        %2211110000%22,%0A        %2201111000%22,%0A        %2200111100%22,%0A        %2200111100%22,%0A        %2200011110%22,%0A        %2200001111%22,%0A        %2200000111%22,%0A        %2200000011%22
 %0A   
@@ -1560,25 +1560,22 @@
 private 
-boolean%5B%5D
+String
 %5B%5D creat
@@ -1613,17 +1613,14 @@
     
-boolean%5B%5D
+String
 %5B%5D c
@@ -1650,214 +1650,74 @@
     
-%7Btrue, true, true, true, false, false, false%7D,%0A        %7Btrue, true, true, true, true, true, false%7D,%0A        %7Bfalse, true, true, true, true, true, true%7D,%0A        %7Bfalse, false, false, true, true, true, true%7D
+%221111000%22,%0A        %221111110%22,%0A        %220111111%22,%0A        %220001111%22
 %0A   

change scb test