Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 package org.ros.internal.node.response;
00018
00019 import java.util.List;
00020
00021 import junit.framework.TestCase;
00022
00023 import org.junit.Test;
00024
00025 import com.google.common.collect.Lists;
00026
00030 public class StringListResultFactoryTest extends TestCase {
00031
00032 @Test
00033 public void testEncodeAndDecode() {
00034 StringListResultFactory factory = new StringListResultFactory();
00035 List<String> expected;
00036 List<String> value;
00037
00038 expected = Lists.newArrayList();
00039 value = factory.newFromValue(new Object[] {});
00040 assertEquals(expected, value);
00041 value = factory.newFromValue(new String[] {});
00042 assertEquals(expected, value);
00043
00044 expected = Lists.newArrayList(new String[] { "foo" });
00045 value = factory.newFromValue(new Object[] { "foo" });
00046 assertEquals(expected, value);
00047 value = factory.newFromValue(new String[] { "foo" });
00048 assertEquals(expected, value);
00049
00050 expected = Lists.newArrayList(new String[] { "foo", "bar" });
00051 value = factory.newFromValue(new Object[] { "foo", "bar" });
00052 assertEquals(expected, value);
00053 value = factory.newFromValue(new String[] { "foo", "bar" });
00054 assertEquals(expected, value);
00055
00056 try {
00057 factory.newFromValue("bad");
00058 fail("should not have converted");
00059 } catch (ClassCastException e) {
00060 }
00061 try {
00062 factory.newFromValue(new Object[] { 1 });
00063 fail("should not have converted");
00064 } catch (ClassCastException e) {
00065 }
00066 try {
00067 factory.newFromValue(new Object[] { "1", 1 });
00068 fail("should not have converted");
00069 } catch (ClassCastException e) {
00070 }
00071 }
00072 }