| Nils Diewald | fe6a365 | 2015-02-05 20:34:27 +0000 | [diff] [blame^] | 1 | package de.ids_mannheim.korap.util; |
| 2 | |
| 3 | import static org.junit.Assert.assertEquals; |
| 4 | import org.junit.Test; |
| 5 | |
| 6 | import static de.ids_mannheim.korap.util.KorapByte.*; |
| 7 | import de.ids_mannheim.korap.util.QueryException; |
| 8 | import java.nio.ByteBuffer; |
| 9 | |
| 10 | /** |
| 11 | * @author diewald |
| 12 | */ |
| 13 | public class TestKorapByte { |
| 14 | |
| 15 | @Test |
| 16 | public void testConversion() { |
| 17 | assertEquals(4, byte2int(int2byte(4))); |
| 18 | assertEquals( |
| 19 | byte2int(ByteBuffer.allocate(4).putInt(4).array()), |
| 20 | byte2int(int2byte(4)) |
| 21 | ); |
| 22 | |
| 23 | assertEquals( |
| 24 | byte2int(ByteBuffer.allocate(4).putInt(99999).array()), |
| 25 | byte2int(int2byte(99999)) |
| 26 | ); |
| 27 | |
| 28 | assertEquals(128, byte2int(int2byte(128))); |
| 29 | assertEquals(1024, byte2int(int2byte(1024))); |
| 30 | assertEquals(66_666, byte2int(int2byte(66_666))); |
| 31 | assertEquals(66_666, byte2int(int2byte(66_666)), 0); |
| 32 | }; |
| 33 | }; |