| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
package uk.me.parabola.imgfmt.app.dem; |
| 14 |
|
| 15 |
import static org.junit.Assert.assertEquals; |
| 16 |
|
| 17 |
import java.util.Arrays; |
| 18 |
|
| 19 |
import org.junit.Test; |
| 20 |
|
| 21 |
import uk.me.parabola.mkgmap.reader.hgt.HGTReader; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
public class DemTileTest { |
| 29 |
|
| 30 |
@Test |
| 31 |
public void testKnownBitstream() throws Exception { |
| 32 |
|
| 33 |
short[] realHeights = new short[64*64]; |
| 34 |
realHeights[63 * 64] = 3; |
| 35 |
DEMTile dt = new DEMTile(0, 0, 64,64, realHeights); |
| 36 |
int bsLen = dt.getBitStreamLen(); |
| 37 |
byte[] exprectedRes = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xC0, 0x2e}; |
| 38 |
assertEquals(12, bsLen); |
| 39 |
String res = Arrays.toString(dt.getBitStream()); |
| 40 |
assertEquals(Arrays.toString(exprectedRes), res); |
| 41 |
} |
| 42 |
|
| 43 |
@Test |
| 44 |
public void testAllZero() throws Exception { |
| 45 |
short[] realHeights = new short[64*64]; |
| 46 |
DEMTile dt = new DEMTile(0, 0, 64,64, realHeights); |
| 47 |
int bsLen = dt.getBitStreamLen(); |
| 48 |
assertEquals(0, bsLen); |
| 49 |
assertEquals(0, dt.getBaseHeight()); |
| 50 |
assertEquals(0, dt.getMaxDeltaHeight()); |
| 51 |
assertEquals(0, dt.getEncodingType()); |
| 52 |
} |
| 53 |
|
| 54 |
@Test |
| 55 |
public void testAllOne() throws Exception { |
| 56 |
short[] realHeights = new short[64*64]; |
| 57 |
Arrays.fill(realHeights, (short)1); |
| 58 |
DEMTile dt = new DEMTile(0, 0, 64,64, realHeights); |
| 59 |
int bsLen = dt.getBitStreamLen(); |
| 60 |
assertEquals(0, bsLen); |
| 61 |
assertEquals(1, dt.getBaseHeight()); |
| 62 |
assertEquals(0, dt.getMaxDeltaHeight()); |
| 63 |
assertEquals(0, dt.getEncodingType()); |
| 64 |
} |
| 65 |
|
| 66 |
@Test |
| 67 |
public void testAllZeroOneUndef() throws Exception { |
| 68 |
short[] realHeights = new short[64*64]; |
| 69 |
realHeights[63 * 64] = HGTReader.UNDEF; |
| 70 |
byte[] exprectedRes = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xC0, 0x3e}; |
| 71 |
DEMTile dt = new DEMTile(0, 0, 64,64, realHeights); |
| 72 |
int bsLen = dt.getBitStreamLen(); |
| 73 |
assertEquals(12, bsLen); |
| 74 |
assertEquals(0, dt.getBaseHeight()); |
| 75 |
assertEquals(1, dt.getMaxDeltaHeight()); |
| 76 |
assertEquals(2, dt.getEncodingType()); |
| 77 |
String res = Arrays.toString(dt.getBitStream()); |
| 78 |
assertEquals(Arrays.toString(exprectedRes), res); |
| 79 |
} |
| 80 |
} |