OSDN Git Service

JRE1.6と1.7の差を吸収
[mikutoga/TogaGem.git] / src / test / java / jp / sfjp / mikutoga / bin / export / TextExporterTest.java
index d3a07f4..e1af900 100644 (file)
@@ -106,8 +106,12 @@ public class TextExporterTest {
         ByteArrayOutputStream bout = new ByteArrayOutputStream();
 
         exporter = new TextExporter(CS_UTF8);
+        // JRE 1.6 と 1.7 でびみょーに違う
+        float maxb = CS_UTF8.newEncoder().maxBytesPerChar();
+
         exporter.setCharBufSize(1);
-        exporter.setByteBufSize(4);
+        int minb = (int)( StrictMath.floor(maxb) );
+        exporter.setByteBufSize(minb);
         bout.reset();
         try{
             exporter.encodeToByteStream("あいう", bout);
@@ -117,7 +121,8 @@ public class TextExporterTest {
         assertEquals(9, bout.size());
 
         try{
-            exporter.setByteBufSize(3);
+            int failSize = minb - 1;
+            exporter.setByteBufSize(failSize);
             fail();
         }catch(IllegalArgumentException e){
             // GOOD