Exemplo n.º 1
0
  @Test
  public void testDistanceEuclidienne2() throws DataFormatException {
    List<Double> variables = new LinkedList<Double>();
    for (double d : p.getVariables()) variables.add(d);
    InfinitePoint Point = new InfinitePoint(variables);

    assertTrue(p.distanceEuclidienne(Point) < InfinitePoint.getEpsilon());
  }
Exemplo n.º 2
0
 @Test
 public void testConstructorDD() {
   p = new InfinitePoint(3, 4);
   boolean ok = true;
   ok &= p.getDimension() == 2;
   ok &= p.getVariables().get(0) == 3;
   ok &= p.getVariables().get(1) == 4;
   assertTrue(ok);
 }
Exemplo n.º 3
0
  @Test
  public void testscaleSize() {

    LinkedList<Double> variables = new LinkedList<Double>();
    double scale = 2;
    for (double d : p.getVariables()) variables.add(d);

    p.scale(scale);
    boolean equals = (p.getVariables().size() == variables.size());
    assertTrue(equals);
  }
Exemplo n.º 4
0
  @Test
  public void testAddValues() throws DataFormatException {

    List<Double> variables = new LinkedList<Double>();
    for (double d : p.getVariables()) variables.add(d);

    InfinitePoint plocal = new InfinitePoint(variables);

    boolean equals = (p.add(plocal) == 0);
    for (int i = 0; i < variables.size(); i++) {
      equals = equals && (2 * variables.get(i) == p.getVariables().get(i));
    }

    assertTrue(equals);
  }
Exemplo n.º 5
0
 @Test
 public void testConstructorSize() {
   int size = 20;
   p = new InfinitePoint(size);
   boolean ok = true;
   for (int i = 0; i < size; i++) {
     ok &= p.getVariables().get(i) == 0;
   }
   assertTrue(ok);
 }
Exemplo n.º 6
0
 @Test
 public void testAdd() {
   InfinitePoint wrongPoint = new InfinitePoint(4);
   boolean exceptionThrown = false;
   try {
     p.add(wrongPoint);
   } catch (DataFormatException e) {
     exceptionThrown = true;
   }
   assertTrue(exceptionThrown);
 }
Exemplo n.º 7
0
  public void testisNotEqualTo() throws DataFormatException {
    LinkedList<Double> variables = new LinkedList<Double>();
    variables.add(1.);
    variables.add(2.);
    variables.add(3.);
    variables.add(4.);
    variables.add(4.);
    InfinitePoint p2 = new InfinitePoint(variables);

    assertTrue(!p.isEqualTo(p2));
  }
Exemplo n.º 8
0
 @Test
 public void testDistanceEuclidienne() {
   InfinitePoint wrongPoint = new InfinitePoint(4);
   boolean exceptionThrown = false;
   try {
     p.distanceEuclidienne(wrongPoint);
   } catch (DataFormatException e) {
     exceptionThrown = true;
   }
   assertTrue(exceptionThrown);
 }
Exemplo n.º 9
0
  @Test
  public void testConstructorVariables() {
    int size = 20;
    List<Double> list = new LinkedList<Double>();
    for (int i = 0; i < size; i++) {
      list.add(i * 1.0);
    }

    p = new InfinitePoint(list);
    boolean ok = true;
    for (int i = 0; i < size; i++) {
      ok &= p.getVariables().get(i) == i;
    }
    assertTrue(ok);
  }
Exemplo n.º 10
0
  @Test
  public void testscaleValues() {

    LinkedList<Double> variables = new LinkedList<Double>();
    double scale = 2;
    for (double d : p.getVariables()) variables.add(d);

    p.scale(scale);
    boolean equals = (p.getVariables().size() == variables.size());
    for (int i = 0; i < p.getVariables().size(); i++)
      equals =
          equals
              && (Math.abs(p.getVariables().get(i) - variables.get(i))
                  < InfinitePoint.getEpsilon());
  }
Exemplo n.º 11
0
 @Test
 public void testGetDimension() {
   p = new InfinitePoint(20);
   assertTrue(p.getDimension() == 20);
 }
Exemplo n.º 12
0
 @Test
 public void testString2() {
   p = new InfinitePoint(0);
   assertTrue(p.toString().contentEquals("[]"));
 }
Exemplo n.º 13
0
 @Test
 public void testString() {
   assertTrue(p.toString().contentEquals("[1.0, 2.0, 3.0, 4.0, 5.0]"));
 }