### Question:
Primitives { public static Character[] wrap(final char[] primitives) { if (primitives == null) return null; if (primitives.length == 0) return new Character[0]; return Arrays.gen(primitives.length, new GenCall<Character>() { public Character gen(int index, int size) { return new Character(primitives[index]); } }); } private  Primitives(); static Character[] wrap(final char[] primitives); static Integer[] wrap(final int[] primitives); static Float[] wrap(final float[] primitives); static Double[] wrap(final double[] primitives); static Byte[] wrap(final byte[] primitives); static Long[] wrap(final long[] primitives);  }### Answer:
@Test public void charからCharacter変換() { char[] suspect = null; assertThat(Primitives.wrap(suspect), nullValue()); suspect = new char[] {}; assertThat(Primitives.wrap(suspect).length, is(0)); suspect = new char[] { 'a' }; assertThat(Primitives.wrap(suspect).length, is(1)); assertThat(Primitives.wrap(suspect)[0], isA(Character.class)); assertThat(Primitives.wrap(suspect)[0].charValue(), is('a')); }
@Test public void intからInteger変換() { int[] suspect = null; assertThat(Primitives.wrap(suspect), nullValue()); suspect = new int[] {}; assertThat(Primitives.wrap(suspect).length, is(0)); suspect = new int[] { 1 }; assertThat(Primitives.wrap(suspect).length, is(1)); assertThat(Primitives.wrap(suspect)[0], isA(Integer.class)); assertThat(Primitives.wrap(suspect)[0].intValue(), is(1)); }
@Test public void longからLong変換() { long[] suspect = null; assertThat(Primitives.wrap(suspect), nullValue()); suspect = new long[] {}; assertThat(Primitives.wrap(suspect).length, is(0)); suspect = new long[] { 10000000000L }; assertThat(Primitives.wrap(suspect).length, is(1)); assertThat(Primitives.wrap(suspect)[0], isA(Long.class)); assertThat(Primitives.wrap(suspect)[0].longValue(), is(10000000000L)); }
@Test public void floatからFloat変換() { float[] suspect = null; assertThat(Primitives.wrap(suspect), nullValue()); suspect = new float[] {}; assertThat(Primitives.wrap(suspect).length, is(0)); suspect = new float[] { 255.255f }; assertThat(Primitives.wrap(suspect).length, is(1)); assertThat(Primitives.wrap(suspect)[0], isA(Float.class)); assertThat(Primitives.wrap(suspect)[0].floatValue(), is(255.255f)); }
@Test public void doubleからDouble変換() { double[] suspect = null; assertThat(Primitives.wrap(suspect), nullValue()); suspect = new double[] {}; assertThat(Primitives.wrap(suspect).length, is(0)); suspect = new double[] { 255.255d }; assertThat(Primitives.wrap(suspect).length, is(1)); assertThat(Primitives.wrap(suspect)[0], isA(Double.class)); assertThat(Primitives.wrap(suspect)[0].doubleValue(), is(255.255d)); }
@Test public void byteからByte変換() { byte[] suspect = null; assertThat(Primitives.wrap(suspect), nullValue()); suspect = new byte[] {}; assertThat(Primitives.wrap(suspect).length, is(0)); suspect = "a".getBytes(); assertThat(Primitives.wrap(suspect).length, is(1)); assertThat(Primitives.wrap(suspect)[0], isA(Byte.class)); }