Package com.aptana.shared_core.io

Examples of com.aptana.shared_core.io.ExtendedByteArrayOutputStream


        o = interpreter.eval("var a = 10;");
        assertEquals(Undefined.instance, o);
        o = interpreter.eval("a");
        assertEquals(10, o);

        ExtendedByteArrayOutputStream out = new ExtendedByteArrayOutputStream();
        interpreter.setOut(out);
        interpreter.setErr(out);
        o = interpreter.eval("print(a)");
        assertEquals("10", out.readAndDelete().trim());
        try {
            interpreter.eval("var a = function(){");
            fail("Expected error on evaluation (function not finished).");
        } catch (EvaluatorException e) {
        }
View Full Code Here


import junit.framework.TestCase;

public class MyByteArrayOutputStreamTest extends TestCase {

    public void testIt() throws Exception {
        ExtendedByteArrayOutputStream myByteArrayOutputStream = new ExtendedByteArrayOutputStream();
        myByteArrayOutputStream.write(new byte[] { 4, 10 });
        assertEquals(2, myByteArrayOutputStream.size());
        assertEquals(4, myByteArrayOutputStream.deleteFirst());

        assertEquals(1, myByteArrayOutputStream.size());
        assertEquals(10, myByteArrayOutputStream.deleteFirst());

        assertEquals(0, myByteArrayOutputStream.size());

        myByteArrayOutputStream.write(new byte[] { 1, 2, 3, 4 });
        byte[] b = new byte[2];
        assertEquals(2, myByteArrayOutputStream.delete(b, 0, 2));
        assertEquals(1, b[0]);
        assertEquals(2, b[1]);
        assertEquals(2, myByteArrayOutputStream.size());

        assertEquals(2, myByteArrayOutputStream.delete(b, 0, 2));
        assertEquals(3, b[0]);
        assertEquals(4, b[1]);
        assertEquals(0, myByteArrayOutputStream.size());

        assertEquals(0, myByteArrayOutputStream.delete(b, 0, 2));
        myByteArrayOutputStream.write(new byte[] { 7 });

        assertEquals(1, myByteArrayOutputStream.delete(b, 0, 2));
        assertEquals(7, b[0]);

        b = new byte[1024];
        myByteArrayOutputStream.write(new byte[] { 1, 2, 3, 4 });
        assertEquals(4, myByteArrayOutputStream.delete(b, 0, 1024));

        myByteArrayOutputStream.write(new byte[] { 1, 2 });
        assertEquals(2, myByteArrayOutputStream.delete(b, 0, 1024));

        myByteArrayOutputStream = new ExtendedByteArrayOutputStream(5);
        myByteArrayOutputStream.write(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
        assertEquals(10, myByteArrayOutputStream.delete(b, 512, 1024));
    }
View Full Code Here

TOP

Related Classes of com.aptana.shared_core.io.ExtendedByteArrayOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.