1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
/**
* @author Mathilde Pellerin
* @date 29 avr. 2010
*/
package fr.statlife.LAM.test;
import fr.statlife.LAM.Matrice;
import fr.statlife.LAM.TabInt;
import junit.framework.TestCase;
/**
* @author Mathilde Pellerin
*
*/
public class MatriceTest extends TestCase
{
private Matrice mtx;
protected void setUp() throws Exception
{
super.setUp();
int[][] tab2D = {{3,2,1},{2,9,4},{6,1,3}};
this.mtx = new Matrice(tab2D);
}
protected void tearDown() throws Exception
{
super.tearDown();
mtx = null;
}
public void testNonBloquant1()
{
int[][] tab2D = {{1,2,3},{2,4,9},{1,3,6}};
Matrice mtxDifferente = new Matrice(tab2D);
assertEquals(mtxDifferente, mtx);
}
public void testNonBloquant2()
{
Matrice mtxDiff = constructionMatrice();
assertEquals(mtxDiff, mtxDiff);
}
public void testBloquant()
{
Matrice mtxDiff = constructionMatrice();
assertEquals(mtxDiff, mtx);
}
private Matrice constructionMatrice()
{
int [][]tab2D = new int[600][640];
for(int i = 0; i<600; i++)
{
int val = 0;
int nbVal = 0;
for(int j = 0; j<640; j++)
{
//si la valeur est paire
//on en met 3 a la suite
if(val%2 == 0)
{
if(nbVal < 3)
{
nbVal ++;
}
else
{
val++;
nbVal = 1;
}
tab2D[i][j] = val;
}
else
{
//si la valeur est impaire
//on en met 2 a la suite
if(nbVal < 2)
{
nbVal ++;
}
else
{
val++;
nbVal = 1;
}
tab2D[i][j] = val;
}
}
}
Matrice mtxReduite = new Matrice(tab2D);
return mtxReduite;
}
} |
Partager