75 lines
2.2 KiB
Java
75 lines
2.2 KiB
Java
|
/*
|
||
|
* To change this license header, choose License Headers in Project Properties.
|
||
|
* To change this template file, choose Tools | Templates
|
||
|
* and open the template in the editor.
|
||
|
*/
|
||
|
package strategy_pattern_tests;
|
||
|
|
||
|
import static org.junit.Assert.*;
|
||
|
import org.junit.Test;
|
||
|
import seabedexplorer.data.Data;
|
||
|
import seabedexplorer.data.LaserReading;
|
||
|
import seabedexplorer.submersible.ROV;
|
||
|
import seabedexplorer.submersible.equipment.topographicalmapper.Laser;
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
* @author Super
|
||
|
*/
|
||
|
public class LaserTest {
|
||
|
|
||
|
@Test
|
||
|
public void validAngleTest() {
|
||
|
ROV submersible = new ROV();
|
||
|
|
||
|
Laser equipment = new Laser(submersible, 0.5);
|
||
|
|
||
|
for (int i = 0; i < 100; i++)
|
||
|
equipment.collectData();
|
||
|
|
||
|
Data[] data = equipment.getData().toArray(new Data[100]);
|
||
|
|
||
|
for (int i = 0; i < 100; i++) {
|
||
|
LaserReading current = (LaserReading) data[i];
|
||
|
System.out.println(current.getAngle());
|
||
|
assertTrue(current.getAngle() >= 0 && current.getAngle() <= 90);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
public void correctDepthTest() {
|
||
|
ROV submersible = new ROV();
|
||
|
|
||
|
Laser equipment = new Laser(submersible,0.5);
|
||
|
|
||
|
for (int i = 0; i < 100; i++)
|
||
|
equipment.collectData();
|
||
|
|
||
|
Data[] data = equipment.getData().toArray(new Data[100]);
|
||
|
|
||
|
for (int i = 0; i < 100; i++) {
|
||
|
LaserReading current = (LaserReading) data[i];
|
||
|
System.out.println(current.getAngle() + " " + current.getDepth());
|
||
|
assertEquals(current.getDepth(), 0.5 / Math.tan(current.getAngle() / (180/Math.PI)),0);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
public void validDepthTest() {
|
||
|
ROV submersible = new ROV();
|
||
|
|
||
|
Laser equipment = new Laser(submersible, 0.5);
|
||
|
|
||
|
for (int i = 0; i < 100; i++)
|
||
|
equipment.collectData();
|
||
|
|
||
|
Data[] data = equipment.getData().toArray(new Data[100]);
|
||
|
|
||
|
for (int i = 0; i < 100; i++) {
|
||
|
LaserReading current = (LaserReading) data[i];
|
||
|
System.out.println(current.getDepth());
|
||
|
assertTrue(current.getDepth() >= 0);
|
||
|
}
|
||
|
}
|
||
|
}
|