@Test public void test() throws IOException, ClassNotFoundException { this.test((Serializable) null, true); this.test("test", true); this.test(Boolean.TRUE, true); this.test(Byte.valueOf(Byte.MAX_VALUE), true); this.test(Character.valueOf(Character.MAX_VALUE), true); this.test(Double.valueOf(Double.MAX_VALUE), true); this.test(Float.valueOf(Float.MAX_VALUE), true); this.test(Integer.valueOf(Integer.MAX_VALUE), true); this.test(Long.valueOf(Long.MAX_VALUE), true); this.test(Short.valueOf(Short.MAX_VALUE), true); this.test(new String[] {"test"}, true); this.test(new boolean[] {Boolean.TRUE}, true); this.test(new byte[] {Byte.MAX_VALUE}, true); this.test(new char[] {Character.MAX_VALUE}, true); this.test(new double[] {Double.MAX_VALUE}, true); this.test(new float[] {Float.MAX_VALUE}, true); this.test(new int[] {Integer.MAX_VALUE}, true); this.test(new long[] {Long.MAX_VALUE}, true); this.test(new short[] {Short.MAX_VALUE}, true); this.test(new Boolean[] {Boolean.TRUE}, true); this.test(new Byte[] {Byte.valueOf(Byte.MAX_VALUE)}, true); this.test(new Character[] {Character.valueOf(Character.MAX_VALUE)}, true); this.test(new Double[] {Double.valueOf(Double.MAX_VALUE)}, true); this.test(new Float[] {Float.valueOf(Float.MAX_VALUE)}, true); this.test(new Integer[] {Integer.valueOf(Integer.MAX_VALUE)}, true); this.test(new Long[] {Long.valueOf(Long.MAX_VALUE)}, true); this.test(new Short[] {Short.valueOf(Short.MAX_VALUE)}, true); this.test(this.getClass(), false); this.test(new Date(System.currentTimeMillis()), false); this.test(new Object(), false); }
@Test public void stringSerialization() { // Characters DataOutput out = serialize.getDataOutput(((int) Character.MAX_VALUE) * 2 + 8, true); for (char c = Character.MIN_VALUE; c < Character.MAX_VALUE; c++) { out.writeObjectNotNull(Character.valueOf(c)); } ReadBuffer b = out.getStaticBuffer().asReadBuffer(); for (char c = Character.MIN_VALUE; c < Character.MAX_VALUE; c++) { assertEquals(c, serialize.readObjectNotNull(b, Character.class).charValue()); } // String for (int t = 0; t < 10000; t++) { DataOutput out1 = serialize.getDataOutput(32 + 5, true); DataOutput out2 = serialize.getDataOutput(32 + 5, true); String s1 = RandomGenerator.randomString(1, 32); String s2 = RandomGenerator.randomString(1, 32); out1.writeObjectNotNull(s1); out2.writeObjectNotNull(s2); StaticBuffer b1 = out1.getStaticBuffer(); StaticBuffer b2 = out2.getStaticBuffer(); assertEquals(s1, serialize.readObjectNotNull(b1.asReadBuffer(), String.class)); assertEquals(s2, serialize.readObjectNotNull(b2.asReadBuffer(), String.class)); assertEquals( s1 + " vs " + s2, Integer.signum(s1.compareTo(s2)), Integer.signum(b1.compareTo(b2))); } }