diff --git a/src/fr/devinsy/strings/StringList.java b/src/fr/devinsy/strings/StringList.java index bf3fb6b..ce19d8d 100644 --- a/src/fr/devinsy/strings/StringList.java +++ b/src/fr/devinsy/strings/StringList.java @@ -56,7 +56,7 @@ public class StringList extends ArrayList implements CharSequence, Appen * @param source * the source */ - public StringList(final boolean... source) + public StringList(final boolean[] source) { super(); @@ -77,7 +77,7 @@ public class StringList extends ArrayList implements CharSequence, Appen * @param source * the source */ - public StringList(final char... source) + public StringList(final char[] source) { super(); @@ -120,7 +120,7 @@ public class StringList extends ArrayList implements CharSequence, Appen * @param source * the source */ - public StringList(final double... source) + public StringList(final double[] source) { super(); @@ -141,7 +141,7 @@ public class StringList extends ArrayList implements CharSequence, Appen * @param source * the source */ - public StringList(final float... source) + public StringList(final float[] source) { super(); @@ -173,7 +173,7 @@ public class StringList extends ArrayList implements CharSequence, Appen * @param source * the source */ - public StringList(final int... source) + public StringList(final int[] source) { super(); @@ -194,7 +194,7 @@ public class StringList extends ArrayList implements CharSequence, Appen * @param source * the source */ - public StringList(final long... source) + public StringList(final long[] source) { super(); @@ -243,7 +243,7 @@ public class StringList extends ArrayList implements CharSequence, Appen * @param source * the source */ - public StringList(final short... source) + public StringList(final short[] source) { super(); @@ -281,31 +281,6 @@ public class StringList extends ArrayList implements CharSequence, Appen } } - /** - * Appends the string of the array argument to this string list. - * - * @param values - * the values - * @return the string list - */ - public StringList append(final boolean... values) - { - StringList result; - - if (values != null) - { - for (boolean value : values) - { - this.append(value); - } - } - - result = this; - - // - return result; - } - /* (non-Javadoc) * @see java.lang.Appendable#append(char) */ diff --git a/test/fr/devinsy/strings/StringListTest.java b/test/fr/devinsy/strings/StringListTest.java index 93aeecf..fcedf19 100644 --- a/test/fr/devinsy/strings/StringListTest.java +++ b/test/fr/devinsy/strings/StringListTest.java @@ -209,6 +209,118 @@ public class StringListTest this.logger.debug("===== test done."); } + /** + * Test constructor 03. + */ + @Test + public void testConstructor03() + { + // + this.logger.debug("===== test starting..."); + + // + StringList target; + + // Boolean. + target = new StringList(true, true, false); + Assert.assertEquals(3, target.size()); + Assert.assertEquals("true,true,false", target.toStringWithCommas()); + + target = new StringList(new boolean[] { true, true, false }); + Assert.assertEquals(3, target.size()); + Assert.assertEquals("true,true,false", target.toStringWithCommas()); + + target = new StringList(new Boolean[] { true, true, false }); + Assert.assertEquals(3, target.size()); + Assert.assertEquals("true,true,false", target.toStringWithCommas()); + + // Char. + target = new StringList('a', 'b', 'c'); + Assert.assertEquals(3, target.size()); + Assert.assertEquals("a,b,c", target.toStringWithCommas()); + + target = new StringList(new char[] { 'a', 'b', (char) 67 }); + Assert.assertEquals(3, target.size()); + Assert.assertEquals("a,b,C", target.toStringWithCommas()); + + target = new StringList(new Character[] { 'a', 'b', 'c' }); + Assert.assertEquals(3, target.size()); + Assert.assertEquals("a,b,c", target.toStringWithCommas()); + + // Short. + target = new StringList((short) 0, (short) 1, (short) 2); + Assert.assertEquals(3, target.size()); + Assert.assertEquals("0,1,2", target.toStringWithCommas()); + + target = new StringList(new short[] { 0, 1, 2 }); + Assert.assertEquals(3, target.size()); + Assert.assertEquals("0,1,2", target.toStringWithCommas()); + + target = new StringList(new Short[] { 0, 1, 2 }); + Assert.assertEquals(3, target.size()); + Assert.assertEquals("0,1,2", target.toStringWithCommas()); + + // Integer. + target = new StringList(0, 1, 2); + Assert.assertEquals(3, target.size()); + Assert.assertEquals("0,1,2", target.toStringWithCommas()); + + target = new StringList(new int[] { 0, 1, 2 }); + Assert.assertEquals(3, target.size()); + Assert.assertEquals("0,1,2", target.toStringWithCommas()); + + target = new StringList(new Integer[] { 0, 1, 2 }); + Assert.assertEquals(3, target.size()); + Assert.assertEquals("0,1,2", target.toStringWithCommas()); + + // Long. + target = new StringList(0L, 1L, 2L); + Assert.assertEquals(3, target.size()); + Assert.assertEquals("0,1,2", target.toStringWithCommas()); + + target = new StringList(new long[] { 0L, 1L, 2L }); + Assert.assertEquals(3, target.size()); + Assert.assertEquals("0,1,2", target.toStringWithCommas()); + + target = new StringList(new Long[] { 0L, 1L, 2L }); + Assert.assertEquals(3, target.size()); + Assert.assertEquals("0,1,2", target.toStringWithCommas()); + + // Double. + target = new StringList(0.1d, 1.1d, 2.2d); + Assert.assertEquals(3, target.size()); + Assert.assertEquals("0.1,1.1,2.2", target.toStringWithCommas()); + + target = new StringList(new double[] { 0.1d, 1.1d, 2.2d }); + Assert.assertEquals(3, target.size()); + Assert.assertEquals("0.1,1.1,2.2", target.toStringWithCommas()); + + target = new StringList(new Double[] { 0.1d, 1.1d, 2.2d }); + Assert.assertEquals(3, target.size()); + Assert.assertEquals("0.1,1.1,2.2", target.toStringWithCommas()); + + // Float. + target = new StringList(0.1f, 1.1f, 2.2f); + Assert.assertEquals(3, target.size()); + Assert.assertEquals("0.1,1.1,2.2", target.toStringWithCommas()); + + target = new StringList(new float[] { 0.1f, 1.1f, 2.2f }); + Assert.assertEquals(3, target.size()); + Assert.assertEquals("0.1,1.1,2.2", target.toStringWithCommas()); + + target = new StringList(new Float[] { 0.1f, 1.1f, 2.2f }); + Assert.assertEquals(3, target.size()); + Assert.assertEquals("0.1,1.1,2.2", target.toStringWithCommas()); + + // Foo. + target = new StringList(true, 1, 1.1, 2L, 3); + Assert.assertEquals(5, target.size()); + Assert.assertEquals("true,1,1.1,2,3", target.toStringWithCommas()); + + // + this.logger.debug("===== test done."); + } + /** * Test contains 01. */