changes for arrays
[lwes-java.git] / src / test / java / org / lwes / serializer / SerializerTest.java
blob74d1fb10bfdab810ad1cb40f9c8a092595328b03
1 package org.lwes.serializer;
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNotNull;
5 import org.junit.Test;
7 /**
8 * @author fmaritato
9 */
11 public class SerializerTest {
13 @Test
14 public void testSerializeStringArray() {
15 String[] array = new String[]{
16 "test", "one", "two", "three"
19 byte[] bytes = new byte[30];
20 int offset = 0;
21 short encoding = 1;
22 int numbytes = Serializer.serializeStringArray(array,
23 bytes,
24 offset,
25 encoding);
26 assertEquals("Number of bytes serialized incorrect", 25, numbytes);
27 DeserializerState state = new DeserializerState();
28 String[] a = Deserializer.deserializeStringArray(state, bytes, encoding);
29 assertNotNull(a);
30 assertEquals("wrong number of elements", 4, a.length);
31 for (int i = 0; i < a.length; i++) {
32 assertEquals("Element "+i+" incorrect", array[i], a[i]);