From 05752a4629598f3c9d32ac42a8fd5e139f0fe16b Mon Sep 17 00:00:00 2001 From: Ernesto Corbellini Date: Wed, 5 Apr 2017 18:14:44 -0300 Subject: [PATCH 1/4] Add some tests for fixed size arrays. --- .../message/RawMessageSerializationTest.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/message_generation/src/test/java/org/ros/internal/message/RawMessageSerializationTest.java b/message_generation/src/test/java/org/ros/internal/message/RawMessageSerializationTest.java index 4f3ce919..5c4a113b 100644 --- a/message_generation/src/test/java/org/ros/internal/message/RawMessageSerializationTest.java +++ b/message_generation/src/test/java/org/ros/internal/message/RawMessageSerializationTest.java @@ -266,4 +266,38 @@ public void testFloat64Array() { rawMessage.setFloat64Array("data", new double[] { 1, 2, 3, 4, 5 }); checkSerializeAndDeserialize(rawMessage); } + + @Test + public void testChannelBufferFixedSizeWithInitialization() { + topicDefinitionResourceProvider.add("foo/foo", "uint8[5] data"); + ChannelBuffer buffer = MessageBuffers.dynamicBuffer(); + buffer.writeBytes(new byte[] { 1, 2, 3, 4, 5 }); + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); + rawMessage.setChannelBuffer("data", buffer); + checkSerializeAndDeserialize(rawMessage); + } + + @Test + public void testChannelBufferFixedSizeNoInitialization() { + topicDefinitionResourceProvider.add("foo/foo", "uint8[5] data"); + ChannelBuffer buffer = MessageBuffers.dynamicBuffer(); + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); + rawMessage.setChannelBuffer("data", buffer); + checkSerializeAndDeserialize(rawMessage); + } + + @Test + public void testInt32FixedSizeArrayWithInitialization() { + topicDefinitionResourceProvider.add("foo/foo", "int32[5] data"); + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); + rawMessage.setInt32Array("data", new int[] { 1, 2, 3, 4, 5 }); + checkSerializeAndDeserialize(rawMessage); + } + + @Test + public void testInt32FixedSizeArrayNoInitialization() { + topicDefinitionResourceProvider.add("foo/foo", "int32[5] data"); + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); + checkSerializeAndDeserialize(rawMessage); + } } From adf060788e972ddf5f64d6775cee9c210afea422 Mon Sep 17 00:00:00 2001 From: Ernesto Corbellini Date: Tue, 10 Apr 2018 13:40:09 -0300 Subject: [PATCH 2/4] Add tests for fixed sized arrays of floats. --- .../message/RawMessageSerializationTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/message_generation/src/test/java/org/ros/internal/message/RawMessageSerializationTest.java b/message_generation/src/test/java/org/ros/internal/message/RawMessageSerializationTest.java index 5c4a113b..529bb61b 100644 --- a/message_generation/src/test/java/org/ros/internal/message/RawMessageSerializationTest.java +++ b/message_generation/src/test/java/org/ros/internal/message/RawMessageSerializationTest.java @@ -300,4 +300,19 @@ public void testInt32FixedSizeArrayNoInitialization() { RawMessage rawMessage = messageFactory.newFromType("foo/foo"); checkSerializeAndDeserialize(rawMessage); } + + @Test + public void testFloat64FixedSizeArrayWithInitialization() { + topicDefinitionResourceProvider.add("foo/foo", "float64[5] data"); + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); + rawMessage.setFloat64Array("data", new double[] { 1, 2, 3, 4, 5 }); + checkSerializeAndDeserialize(rawMessage); + } + + @Test + public void testFloat64FixedSizeArrayNoInitialization() { + topicDefinitionResourceProvider.add("foo/foo", "float64[5] data"); + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); + checkSerializeAndDeserialize(rawMessage); + } } From 2e3c1d96e3560c2de1938e045ecc15dfe55d3d4f Mon Sep 17 00:00:00 2001 From: Ernesto Corbellini Date: Wed, 11 Apr 2018 13:22:30 -0300 Subject: [PATCH 3/4] Add tests for incomplete initialization and string arrays. --- .../message/RawMessageSerializationTest.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/message_generation/src/test/java/org/ros/internal/message/RawMessageSerializationTest.java b/message_generation/src/test/java/org/ros/internal/message/RawMessageSerializationTest.java index 529bb61b..aa131b95 100644 --- a/message_generation/src/test/java/org/ros/internal/message/RawMessageSerializationTest.java +++ b/message_generation/src/test/java/org/ros/internal/message/RawMessageSerializationTest.java @@ -19,6 +19,7 @@ import static org.junit.Assert.assertTrue; import com.google.common.collect.Lists; +import java.util.Arrays; import org.jboss.netty.buffer.ChannelBuffer; import org.junit.Before; @@ -277,6 +278,16 @@ public void testChannelBufferFixedSizeWithInitialization() { checkSerializeAndDeserialize(rawMessage); } + @Test + public void testChannelBufferFixedSizeWithIncompleteInitialization() { + topicDefinitionResourceProvider.add("foo/foo", "uint8[5] data"); + ChannelBuffer buffer = MessageBuffers.dynamicBuffer(); + buffer.writeBytes(new byte[] { 1, 2, 3 }); + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); + rawMessage.setChannelBuffer("data", buffer); + checkSerializeAndDeserialize(rawMessage); + } + @Test public void testChannelBufferFixedSizeNoInitialization() { topicDefinitionResourceProvider.add("foo/foo", "uint8[5] data"); @@ -294,6 +305,14 @@ public void testInt32FixedSizeArrayWithInitialization() { checkSerializeAndDeserialize(rawMessage); } + @Test + public void testInt32FixedSizeArrayWithIncompleteInitialization() { + topicDefinitionResourceProvider.add("foo/foo", "int32[5] data"); + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); + rawMessage.setInt32Array("data", new int[] { 1, 2, 3 }); + checkSerializeAndDeserialize(rawMessage); + } + @Test public void testInt32FixedSizeArrayNoInitialization() { topicDefinitionResourceProvider.add("foo/foo", "int32[5] data"); @@ -308,6 +327,14 @@ public void testFloat64FixedSizeArrayWithInitialization() { rawMessage.setFloat64Array("data", new double[] { 1, 2, 3, 4, 5 }); checkSerializeAndDeserialize(rawMessage); } + + @Test + public void testFloat64FixedSizeArrayWithIncompleteInitialization() { + topicDefinitionResourceProvider.add("foo/foo", "float64[5] data"); + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); + rawMessage.setFloat64Array("data", new double[] { 1, 2, 3 }); + checkSerializeAndDeserialize(rawMessage); + } @Test public void testFloat64FixedSizeArrayNoInitialization() { @@ -315,4 +342,29 @@ public void testFloat64FixedSizeArrayNoInitialization() { RawMessage rawMessage = messageFactory.newFromType("foo/foo"); checkSerializeAndDeserialize(rawMessage); } + + @Test + public void testStringFixedSizeArrayWithInitialization() { + topicDefinitionResourceProvider.add("foo/foo", "string[5] data"); + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); + String[] stringArray = new String[] { "String 1", "String 2", "String 3", "String 4", "String 5" }; + rawMessage.setStringList("data", Arrays.asList(stringArray)); + checkSerializeAndDeserialize(rawMessage); + } + + @Test + public void testStringFixedSizeArrayWithIncompleteInitialization() { + topicDefinitionResourceProvider.add("foo/foo", "string[5] data"); + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); + String[] stringArray = new String[] { "String 1", "String 2", "String 3" }; + rawMessage.setStringList("data", Arrays.asList(stringArray)); + checkSerializeAndDeserialize(rawMessage); + } + + @Test + public void testStringFixedSizeArrayWithNoInitialization() { + topicDefinitionResourceProvider.add("foo/foo", "string[5] data"); + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); + checkSerializeAndDeserialize(rawMessage); + } } From fe6c536517920b257ec3faaec8e98b8d2ca629e5 Mon Sep 17 00:00:00 2001 From: Ernesto Corbellini Date: Fri, 13 Apr 2018 18:09:32 -0300 Subject: [PATCH 4/4] Add tests for byte arrays. --- .../message/RawMessageSerializationTest.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/message_generation/src/test/java/org/ros/internal/message/RawMessageSerializationTest.java b/message_generation/src/test/java/org/ros/internal/message/RawMessageSerializationTest.java index aa131b95..cf19530d 100644 --- a/message_generation/src/test/java/org/ros/internal/message/RawMessageSerializationTest.java +++ b/message_generation/src/test/java/org/ros/internal/message/RawMessageSerializationTest.java @@ -367,4 +367,27 @@ public void testStringFixedSizeArrayWithNoInitialization() { RawMessage rawMessage = messageFactory.newFromType("foo/foo"); checkSerializeAndDeserialize(rawMessage); } + + @Test + public void testByteFixedSizeArrayWithInitialization() { + topicDefinitionResourceProvider.add("foo/foo", "byte[5] data"); + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); + rawMessage.setInt8Array("data", new byte[] { 1, 2, 3, 4, 5 }); + checkSerializeAndDeserialize(rawMessage); + } + + @Test + public void testByteFixedSizeArrayWithIncompleteInitialization() { + topicDefinitionResourceProvider.add("foo/foo", "byte[5] data"); + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); + rawMessage.setInt8Array("data", new byte[] { 1, 2, 3 }); + checkSerializeAndDeserialize(rawMessage); + } + + @Test + public void testByteFixedSizeArrayWithNoInitialization() { + topicDefinitionResourceProvider.add("foo/foo", "byte[5] data"); + RawMessage rawMessage = messageFactory.newFromType("foo/foo"); + checkSerializeAndDeserialize(rawMessage); + } }