### Question:
ToStringPrinter extends Printer { @Override protected String serialize(Object input) { if (input instanceof String) { return "\"" + input + "\""; } if (input.getClass().isArray()) { if (input instanceof byte[]) { return Arrays.toString((byte[]) input); } if (input instanceof char[]) { return Arrays.toString((char[]) input); } if (input instanceof int[]) { return Arrays.toString((int[]) input); } if (input instanceof boolean[]) { return Arrays.toString((boolean[]) input); } if (input instanceof short[]) { return Arrays.toString((short[]) input); } if (input instanceof long[]) { return Arrays.toString((long[]) input); } if (input instanceof float[]) { return Arrays.toString((float[]) input); } if (input instanceof double[]) { return Arrays.toString((double[]) input); } return Arrays.toString((Object[]) input); } return input.toString(); }    }### Answer:
@Test public void serializeBytes() { byte[] bytes = new byte[]{1, 2, 3}; String result = printer.serialize(bytes); assertThat(result, is("[1, 2, 3]")); }
@Test public void serializeChars() { char[] chars = new char[]{'a', 'b', 'c'}; String result = printer.serialize(chars); assertThat(result, is("[a, b, c]")); }
@Test public void serializeInts() { int[] ints = new int[]{1, 2, 3}; String result = printer.serialize(ints); assertThat(result, is("[1, 2, 3]")); }
@Test public void serializeBooleans() { boolean[] booleans = new boolean[]{false, true, false}; String result = printer.serialize(booleans); assertThat(result, is("[false, true, false]")); }
@Test public void serializeShorts() { short[] shorts = new short[]{1, 2, 3}; String result = printer.serialize(shorts); assertThat(result, is("[1, 2, 3]")); }
@Test public void serializeLongs() { long[] longs = new long[]{1, 2, 3}; String result = printer.serialize(longs); assertThat(result, is("[1, 2, 3]")); }
@Test public void serializeFloats() { float[] floats = new float[]{1, 2, 3}; String result = printer.serialize(floats); assertThat(result, is("[1.0, 2.0, 3.0]")); }
@Test public void serializeDoubles() { double[] doubles = new double[]{1, 2, 3}; String result = printer.serialize(doubles); assertThat(result, is("[1.0, 2.0, 3.0]")); }
@Test public void serializeObjects() { Object[] objects = new Object[]{new TestObject(), new TestObject(), new TestObject()}; String result = printer.serialize(objects); assertThat(result, is("[!, !, !]")); }
@Test public void serializeObject() { Object object = new TestObject(); String result = printer.serialize(object); assertThat(result, is("!")); }
@Test public void serializeString() { String string = "string"; String result = printer.serialize(string); assertThat(result, is("\"string\"")); }