From 10808e2b7c9d03b82fada20001ddb026c239b2f0 Mon Sep 17 00:00:00 2001 From: Frank Maritato Date: Mon, 16 Nov 2009 19:44:42 +0000 Subject: [PATCH] changes for arrays git-svn-id: https://lwes.svn.sourceforge.net/svnroot/lwes/lwes-java/branches/0.3.0@281 a2f82657-cdd2-4550-bd36-68a8e7111808 --- .../java/org/lwes/serializer/SerializerTest.java | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/test/java/org/lwes/serializer/SerializerTest.java diff --git a/src/test/java/org/lwes/serializer/SerializerTest.java b/src/test/java/org/lwes/serializer/SerializerTest.java new file mode 100644 index 0000000..74d1fb1 --- /dev/null +++ b/src/test/java/org/lwes/serializer/SerializerTest.java @@ -0,0 +1,35 @@ +package org.lwes.serializer; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import org.junit.Test; + +/** + * @author fmaritato + */ + +public class SerializerTest { + + @Test + public void testSerializeStringArray() { + String[] array = new String[]{ + "test", "one", "two", "three" + }; + + byte[] bytes = new byte[30]; + int offset = 0; + short encoding = 1; + int numbytes = Serializer.serializeStringArray(array, + bytes, + offset, + encoding); + assertEquals("Number of bytes serialized incorrect", 25, numbytes); + DeserializerState state = new DeserializerState(); + String[] a = Deserializer.deserializeStringArray(state, bytes, encoding); + assertNotNull(a); + assertEquals("wrong number of elements", 4, a.length); + for (int i = 0; i < a.length; i++) { + assertEquals("Element "+i+" incorrect", array[i], a[i]); + } + } +} -- 2.11.4.GIT