-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Adrián González Sieira
committed
Nov 7, 2018
1 parent
a5c427d
commit c364783
Showing
4 changed files
with
82 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
joctomap-core/src/test/java/es/usc/citius/lab/joctomap/util/MapFileFormatReaderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package es.usc.citius.lab.joctomap.util; | ||
|
||
import org.junit.Test; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class MapFileFormatReaderTest { | ||
|
||
private MapFileReader readerPPM1; | ||
private MapFileReader readerPPM2; | ||
private MapFileReader readerPGM1; | ||
private MapFileReader readerPGM2; | ||
|
||
@Test | ||
public void test01_readPGM() throws IOException, URISyntaxException{ | ||
this.readerPPM1 = new MapFileReader(new File(MapFileReaderTest.class.getClassLoader().getResource("ecmr_ascii.ppm").toURI()).getAbsolutePath()); | ||
this.readerPPM2 = new MapFileReader(new File(MapFileReaderTest.class.getClassLoader().getResource("ecmr_binary.ppm").toURI()).getAbsolutePath()); | ||
assertEquals(this.readerPPM1.getSizeX(), this.readerPPM2.getSizeX()); | ||
assertEquals(this.readerPPM1.getSizeY(), this.readerPPM2.getSizeY()); | ||
assertEquals(this.readerPPM1.getMaxValue(), this.readerPPM2.getMaxValue()); | ||
assertEquals(this.readerPPM1.getPixels().length, this.readerPPM1.getPixels().length); | ||
for(int i = 0; i < this.readerPPM1.getPixels().length; i++){ | ||
assertEquals(this.readerPPM1.getPixels().length, this.readerPPM2.getPixels().length); | ||
for(int j = 0; j < this.readerPPM1.getPixels()[i].length; j++){ | ||
assertEquals(this.readerPPM1.getPixels()[i][j][0], this.readerPPM2.getPixels()[i][j][0]); | ||
assertEquals(this.readerPPM1.getPixels()[i][j][1], this.readerPPM2.getPixels()[i][j][1]); | ||
assertEquals(this.readerPPM1.getPixels()[i][j][2], this.readerPPM2.getPixels()[i][j][2]); | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
public void test03_readPPM() throws IOException, URISyntaxException{ | ||
this.readerPGM1 = new MapFileReader(new File(MapFileReaderTest.class.getClassLoader().getResource("ecmr_ascii.pgm").toURI()).getAbsolutePath()); | ||
this.readerPGM2 = new MapFileReader(new File(MapFileReaderTest.class.getClassLoader().getResource("ecmr_binary.pgm").toURI()).getAbsolutePath()); | ||
assertEquals(this.readerPGM1.getSizeX(), this.readerPGM2.getSizeX()); | ||
assertEquals(this.readerPGM1.getSizeY(), this.readerPGM2.getSizeY()); | ||
assertEquals(this.readerPGM1.getMaxValue(), this.readerPGM2.getMaxValue()); | ||
assertEquals(this.readerPGM1.getPixels().length, this.readerPGM1.getPixels().length); | ||
for(int i = 0; i < this.readerPGM1.getPixels().length; i++){ | ||
assertEquals(this.readerPGM1.getPixels().length, this.readerPGM2.getPixels().length); | ||
for(int j = 0; j < this.readerPGM1.getPixels()[i].length; j++){ | ||
assertEquals(this.readerPGM1.getPixels()[i][j][0], this.readerPGM2.getPixels()[i][j][0]); | ||
assertEquals(this.readerPGM1.getPixels()[i][j][1], this.readerPGM2.getPixels()[i][j][1]); | ||
assertEquals(this.readerPGM1.getPixels()[i][j][2], this.readerPGM2.getPixels()[i][j][2]); | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
public void test05_compareFormats() throws IOException, URISyntaxException{ | ||
this.readerPGM1 = new MapFileReader(new File(MapFileReaderTest.class.getClassLoader().getResource("ecmr_ascii.pgm").toURI()).getAbsolutePath()); | ||
this.readerPPM1 = new MapFileReader(new File(MapFileReaderTest.class.getClassLoader().getResource("ecmr_ascii.ppm").toURI()).getAbsolutePath()); | ||
assertEquals(this.readerPGM1.getSizeX(), this.readerPPM1.getSizeX()); | ||
assertEquals(this.readerPGM1.getSizeY(), this.readerPPM1.getSizeY()); | ||
assertEquals(this.readerPGM1.getMaxValue(), this.readerPPM1.getMaxValue()); | ||
assertEquals(this.readerPGM1.getPixels().length, this.readerPGM1.getPixels().length); | ||
for(int i = 0; i < this.readerPGM1.getPixels().length; i++){ | ||
assertEquals(this.readerPGM1.getPixels().length, this.readerPPM1.getPixels().length); | ||
for(int j = 0; j < this.readerPGM1.getPixels()[i].length; j++){ | ||
assertEquals(this.readerPGM1.getPixels()[i][j][0], this.readerPPM1.getPixels()[i][j][0]); | ||
assertEquals(this.readerPGM1.getPixels()[i][j][1], this.readerPPM1.getPixels()[i][j][1]); | ||
assertEquals(this.readerPGM1.getPixels()[i][j][2], this.readerPPM1.getPixels()[i][j][2]); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,6 @@ | |
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
|
||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
/** | ||
|
@@ -31,19 +30,19 @@ | |
* | ||
* @author Adrián González Sieira {@literal <[email protected]>} | ||
*/ | ||
public class PPMFileReaderTest { | ||
public class MapFileReaderTest { | ||
|
||
private PPMFileReader reader; | ||
/** | ||
private MapFileReader reader; | ||
|
||
/** | ||
* Constructor which loads a resource | ||
* | ||
* @throws FileNotFoundException if file not found | ||
* @throws IOException if I/O error occurs | ||
* @throws URISyntaxException if URI bad formatted | ||
*/ | ||
public PPMFileReaderTest() throws IOException, URISyntaxException{ | ||
this.reader = new PPMFileReader(new File(PPMFileReaderTest.class.getClassLoader().getResource("ecmr.ppm").toURI()).getAbsolutePath()); | ||
public MapFileReaderTest() throws IOException, URISyntaxException{ | ||
this.reader = new MapFileReader(new File(MapFileReaderTest.class.getClassLoader().getResource("ecmr_ascii.ppm").toURI()).getAbsolutePath()); | ||
} | ||
|
||
/** | ||
|