@@ -802,24 +802,36 @@ public void optQueryWithSyntaxError() {
802802 @ Test
803803 public void write () {
804804 String str = "[\" value1\" ,\" value2\" ,{\" key1\" :1,\" key2\" :2,\" key3\" :3}]" ;
805- String expectedStr = str ;
806805 JSONArray jsonArray = new JSONArray (str );
806+ String expectedStr = str ;
807807 StringWriter stringWriter = new StringWriter ();
808808 Writer writer = jsonArray .write (stringWriter );
809809 String actualStr = writer .toString ();
810810 assertTrue ("write() expected " + expectedStr +
811- "but found " + actualStr ,
811+ " but found " + actualStr ,
812812 expectedStr .equals (actualStr ));
813+ }
814+
815+ /**
816+ * Exercise the JSONArray write() method using Appendable.
817+ */
818+ /*
819+ @Test
820+ public void writeAppendable() {
821+ String str = "[\"value1\",\"value2\",{\"key1\":1,\"key2\":2,\"key3\":3}]";
822+ JSONArray jsonArray = new JSONArray(str);
823+ String expectedStr = str;
813824 StringBuilder stringBuilder = new StringBuilder();
814825 Appendable appendable = jsonArray.write(stringBuilder);
815- actualStr = appendable .toString ();
826+ String actualStr = appendable.toString();
816827 assertTrue("write() expected " + expectedStr +
817- "but found " + actualStr ,
828+ " but found " + actualStr,
818829 expectedStr.equals(actualStr));
819830 }
831+ */
820832
821833 /**
822- * Exercise the JSONArray write(Appendable , int, int) method
834+ * Exercise the JSONArray write(Writer , int, int) method
823835 */
824836 @ Test
825837 public void write3Param () {
@@ -834,23 +846,51 @@ public void write3Param() {
834846 " \" key3\" : 3.14\n " +
835847 " }\n " +
836848 " ]" ;
837- String expectedStr = str0 ;
838849 JSONArray jsonArray = new JSONArray (str0 );
850+ String expectedStr = str0 ;
839851 StringWriter stringWriter = new StringWriter ();
840852 Writer writer = jsonArray .write (stringWriter , 0 , 0 );
841853 String actualStr = writer .toString ();
842854 assertEquals (expectedStr , actualStr );
843- expectedStr = str0 ;
855+
856+ expectedStr = str2 ;
857+ stringWriter = new StringWriter ();
858+ writer = jsonArray .write (stringWriter , 2 , 1 );
859+ actualStr = writer .toString ();
860+ assertEquals (expectedStr , actualStr );
861+ }
862+
863+ /**
864+ * Exercise the JSONArray write(Appendable, int, int) method
865+ */
866+ /*
867+ @Test
868+ public void write3ParamAppendable() {
869+ String str0 = "[\"value1\",\"value2\",{\"key1\":1,\"key2\":false,\"key3\":3.14}]";
870+ String str2 =
871+ "[\n" +
872+ " \"value1\",\n" +
873+ " \"value2\",\n" +
874+ " {\n" +
875+ " \"key1\": 1,\n" +
876+ " \"key2\": false,\n" +
877+ " \"key3\": 3.14\n" +
878+ " }\n" +
879+ " ]";
880+ JSONArray jsonArray = new JSONArray(str0);
881+ String expectedStr = str0;
844882 StringBuilder stringBuilder = new StringBuilder();
845883 Appendable appendable = jsonArray.write(stringBuilder, 0, 0);
846- actualStr = appendable .toString ();
884+ String actualStr = appendable.toString();
847885 assertEquals(expectedStr, actualStr);
886+
848887 expectedStr = str2;
849888 stringBuilder = new StringBuilder();
850889 appendable = jsonArray.write(stringBuilder, 2, 1);
851890 actualStr = appendable.toString();
852891 assertEquals(expectedStr, actualStr);
853892 }
893+ */
854894
855895 /**
856896 * Exercise JSONArray toString() method with various indent levels.
0 commit comments