public void testTheMatrix(){
  String matrixString="11,12,13 ; 21,22,23 ; 31,32,33 ; 41,42,43";
  int[][] expected=new int[][]{new int[]{11,12,13},new int[]{21,22,23},new int[]{31,32,33},new int[]{41,42,43}};
  IntegerConverter integerConverter=new IntegerConverter();
  ArrayConverter arrayConverter=new ArrayConverter(int[].class,integerConverter);
  ArrayConverter matrixConverter=new ArrayConverter(int[][].class,arrayConverter);
  matrixConverter.setDelimiter(';');
  matrixConverter.setAllowedChars(new char[]{','});
  try {
    Object result=matrixConverter.convert(int[][].class,matrixString);
    assertEquals("Check int[][].class",int[][].class,result.getClass());
    int[][] matrix=(int[][])result;
    assertEquals("Check int[][] length",expected.length,matrix.length);
    for (int i=0; i < expected.length; i++) {
      assertEquals("Check int[" + i + "] length",expected[i].length,matrix[i].length);
      for (int j=0; j < expected[i].length; j++) {
        String label="Matrix int[" + i + ","+ j+ "] element";
        assertEquals(label,expected[i][j],matrix[i][j]);
      }
    }
  }
 catch (  Exception e) {
    fail("Matrix Conversion threw " + e);
  }
}

public void testTheMatrix ( ) { String matrixString = "11,12,13 ; 21,22,23 ; 31,32,33 ; 41,42,43" ; int [ ] [ ] expected = new int [ ] [ ] { new int [ ] { 11 , 12 , 13 } , new int [ ] { 21 , 22 , 23 } , new int [ ] { 31 , 32 , 33 } , new int [ ] { 41 , 42 , 43 } } ; IntegerConverter integerConverter = new IntegerConverter ( ) ; ArrayConverter arrayConverter = new ArrayConverter ( int [ ] . class , integerConverter ) ; ArrayConverter matrixConverter = new ArrayConverter ( int [ ] [ ] . class , arrayConverter ) ; matrixConverter . setDelimiter ( ';' ) ; matrixConverter . setAllowedChars ( new char [ ] { ',' } ) ; try { Object result = matrixConverter . convert ( int [ ] [ ] . class , matrixString ) ; assertEquals ( "Check int[][].class" , int [ ] [ ] . class , result . getClass ( ) ) ; int [ ] [ ] matrix = ( int [ ] [ ] ) result ; assertEquals ( "Check int[][] length" , expected . length , matrix . length ) ; for ( int i = 0 ; i < expected . length ; i ++ ) { assertEquals ( "Check int[" + i + "] length" , expected [ i ] . length , matrix [ i ] . length ) ; for ( int j = 0 ; j < expected [ i ] . length ; j ++ ) { String label = "Matrix int[" + i + "," + j + "] element" ; assertEquals ( label , expected [ i ] [ j ] , matrix [ i ] [ j ] ) ; } } } catch ( Exception e ) { fail ( "Matrix Conversion threw " + e ) ; } }
test the matrix ! ! ! ! ( parses a string into a 2 dimensional integer array or matrix )
