blob: e106699a6564acb9046c3ab86ca77f26dfdfe234 [file] [log] [blame]
Nils Diewaldfe6a3652015-02-05 20:34:27 +00001package de.ids_mannheim.korap.util;
2
3import static org.junit.Assert.assertEquals;
4import org.junit.Test;
5
6import static de.ids_mannheim.korap.util.KorapByte.*;
7import de.ids_mannheim.korap.util.QueryException;
8import java.nio.ByteBuffer;
9
10/**
11 * @author diewald
12 */
13public 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};