AJsonSerHelper { public void writeBooleanLiteral (boolean value) throws IOException { checkAcceptsValueAndPrefixComma (); out.write (String.valueOf (value)); afterValueWritten (); } AJsonSerHelper(OutputStream out); void startObject(); void endObject(); void writeKey(String key); void startArray(); void endArray(); void writeStringLiteral(String s); void writeNumberLiteral(long value, int numFracDigits); void writeNumberLiteral(double value, int numFracDigits); void writeBooleanLiteral(boolean value); void writeNullLiteral(); void writeIntLiteral(int value); void writeLongLiteral(long value); void writeStringArray(Iterable<String> values); void writeStringField(String key, String value); void writeBooleanField(String key, Boolean value); void writeIntField(String key, Integer value); void writeLongField(String key, Long value); static String buildString(AStatement1<AJsonSerHelper, E> code); static final Charset UTF_8; }
@Test public void testTrue() throws IOException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final AJsonSerHelper ser = new AJsonSerHelper(baos); ser.writeBooleanLiteral(true); final String result = new String(baos.toByteArray(), "utf-8"); assertEquals("true", result); }
@Test public void testFalse() throws IOException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final AJsonSerHelper ser = new AJsonSerHelper(baos); ser.writeBooleanLiteral(false); final String result = new String(baos.toByteArray(), "utf-8"); assertEquals("false", result); }