Index: lutinmatrix/src/test/org/codelutin/math/matrix/gui/MatrixTableModelTest.java diff -u /dev/null lutinmatrix/src/test/org/codelutin/math/matrix/gui/MatrixTableModelTest.java:1.1 --- /dev/null Wed Mar 22 19:39:31 2006 +++ lutinmatrix/src/test/org/codelutin/math/matrix/gui/MatrixTableModelTest.java Wed Mar 22 19:39:26 2006 @@ -0,0 +1,158 @@ +/* *##% + * Copyright (C) 2006 + * Code Lutin, Cédric Pineau, Benjamin Poussin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * MatrixTableModelND.java + * + * Created: 21 mars 2006 19:05:06 + * + * @author poussin + * @version $Revision: 1.1 $ + * + * Last update: $Date: 2006/03/22 19:39:26 $ + * by : $Author: bpoussin $ + */ + +package org.codelutin.math.matrix.gui; + +import java.util.Arrays; +import java.util.List; + +import org.codelutin.math.matrix.MatrixFactory; +import org.codelutin.math.matrix.MatrixND; + +import junit.framework.TestCase; + + +/** + * @author poussin + * + */ + +public class MatrixTableModelTest extends TestCase { + + MatrixTableModelND model = null; + MatrixND mat = null; + + /* + * @see TestCase#setUp() + */ + protected void setUp() throws Exception { + List dim0 = Arrays.asList(new String[]{"dim0-0","dim0-1","dim0-2","dim0-3"}); + List dim1 = Arrays.asList(new String[]{"dim1-0","dim1-1"}); + List dim2 = Arrays.asList(new String[]{"dim2-0","dim2-1"}); + List dim3 = Arrays.asList(new String[]{"dim3-0","dim3-1","dim3-2","dim3-3"}); + List dim4 = Arrays.asList(new String[]{"dim4-0","dim4-1","dim4-2"}); + mat = MatrixFactory.getInstance().create("mat", + new List[]{dim0,dim1,dim2,dim3,dim4}, + new String[]{"dim0","dim1","dim2","dim3","dim4"}); + model = new MatrixTableModelND(mat); + } + + public void testSetMatrix() { + assertEquals(2, model.addRow); + assertEquals(3, model.addCol); + int[] val = model.multRowCol; + assertEquals(true, Arrays.equals(new int[]{6,4,3,1,1}, val)); + } + + /* + * Test method for 'org.codelutin.math.matrix.gui.MatrixTableModelND.isCellEditable(int, int)' + */ + public void testIsCellEditable() { + assertEquals(false, model.isCellEditable(model.addRow - 1, model.addCol - 1)); + assertEquals(true, model.isCellEditable(model.addRow, model.addCol)); + assertEquals(true, model.isCellEditable(model.addRow + 1, model.addCol + 1)); + } + + /* + * Test method for 'org.codelutin.math.matrix.gui.MatrixTableModelND.tableToMatrix(int, int)' + */ + public void testTableToMatrix() { + int[] val = model.tableToMatrix(5, 4); + assertEquals(true, Arrays.equals(new int[]{0, 1, 1, 0, 2}, val)); + val = model.tableToMatrix(0, 0); + assertEquals(true, Arrays.equals(new int[]{0, 0, 0, 0, 0}, val)); + val = model.tableToMatrix(23, 5); + assertEquals(true, Arrays.equals(new int[]{3, 1, 1, 1, 2}, val)); + } + + /* + * Test method for 'org.codelutin.math.matrix.gui.MatrixTableModelND.getValue(int, int)' + */ + public void testGetValue() { + assertEquals("dim0-0", model.getValue(2, 0)); + assertEquals("dim0-0", model.getValue(3, 0)); + assertEquals("dim0-0", model.getValue(4, 0)); + assertEquals("dim0-0", model.getValue(7, 0)); + assertEquals("dim0-1", model.getValue(8, 0)); + + assertEquals("dim2-0", model.getValue(2, 1)); + assertEquals("dim2-0", model.getValue(3, 1)); + assertEquals("dim2-1", model.getValue(5, 1)); + + assertEquals("dim4-0", model.getValue(2, 2)); + assertEquals("dim4-1", model.getValue(3, 2)); + assertEquals("dim4-2", model.getValue(4, 2)); + assertEquals("dim4-0", model.getValue(5, 2)); + + assertEquals("dim1-0", model.getValue(0, 3)); + + assertEquals(0.0, model.getValue(model.addRow, model.addCol)); + assertEquals(0.0, model.getValue(23 + model.addRow, 5 + model.addCol)); + } + + /* + * Test method for 'org.codelutin.math.matrix.gui.MatrixTableModelND.getColumnName(int)' + */ + public void testGetColumnNameInt() { + + } + + /* + * Test method for 'org.codelutin.math.matrix.gui.MatrixTableModelND.getRowCount()' + */ + public void testGetRowCount() { + + } + + /* + * Test method for 'org.codelutin.math.matrix.gui.MatrixTableModelND.getColumnCount()' + */ + public void testGetColumnCount() { + + } + + /* + * Test method for 'org.codelutin.math.matrix.gui.MatrixTableModelND.getValueAt(int, int)' + */ + public void testGetValueAt() { + + } + + /* + * Test method for 'org.codelutin.math.matrix.gui.MatrixTableModelND.setValueAt(Object, int, int)' + */ + public void testSetValueAtObjectIntInt() { + + } + +} + +