Examples of CharArrayBuffer


Examples of org.apache.http.util.CharArrayBuffer

     
      assertEquals("1212341234", buffer.toString());
    }

    public void testAppendString() throws Exception {
      CharArrayBuffer buffer = new CharArrayBuffer(8);
      buffer.append("stuff");
      buffer.append(" and more stuff");
      assertEquals("stuff and more stuff", buffer.toString());
    }
View Full Code Here

Examples of org.apache.http.util.CharArrayBuffer

      buffer.append(" and more stuff");
      assertEquals("stuff and more stuff", buffer.toString());
    }
   
    public void testAppendNullString() throws Exception {
      CharArrayBuffer buffer = new CharArrayBuffer(8);
      buffer.append((String)null);
      assertEquals("null", buffer.toString());
    }
View Full Code Here

Examples of org.apache.http.util.CharArrayBuffer

      buffer.append((String)null);
      assertEquals("null", buffer.toString());
    }
   
    public void testAppendCharArrayBuffer() throws Exception {
        CharArrayBuffer buffer1 = new CharArrayBuffer(8);
        buffer1.append(" and more stuff");
        CharArrayBuffer buffer2 = new CharArrayBuffer(8);
        buffer2.append("stuff");
        buffer2.append(buffer1);
        assertEquals("stuff and more stuff", buffer2.toString());
    }
View Full Code Here

Examples of org.apache.http.util.CharArrayBuffer

        buffer2.append(buffer1);
        assertEquals("stuff and more stuff", buffer2.toString());
    }
   
    public void testAppendNullCharArrayBuffer() throws Exception {
        CharArrayBuffer buffer = new CharArrayBuffer(8);
        buffer.append((CharArrayBuffer)null);
        buffer.append((CharArrayBuffer)null, 0, 0);
        assertEquals("", buffer.toString());
    }
View Full Code Here

Examples of org.apache.http.util.CharArrayBuffer

        buffer.append((CharArrayBuffer)null, 0, 0);
        assertEquals("", buffer.toString());
    }
   
    public void testAppendSingleChar() throws Exception {
      CharArrayBuffer buffer = new CharArrayBuffer(4);
      buffer.append('1');
      buffer.append('2');
      buffer.append('3');
      buffer.append('4');
      buffer.append('5');
      buffer.append('6');
      assertEquals("123456", buffer.toString());
    }
View Full Code Here

Examples of org.apache.http.util.CharArrayBuffer

      buffer.append('6');
      assertEquals("123456", buffer.toString());
    }
   
    public void testInvalidCharArrayAppend() throws Exception {
      CharArrayBuffer buffer = new CharArrayBuffer(4);
      buffer.append((char[])null, 0, 0);

      char[] tmp = new char[] { '1', '2', '3', '4'};
      try {
          buffer.append(tmp, -1, 0);
        fail("IndexOutOfBoundsException should have been thrown");
      } catch (IndexOutOfBoundsException ex) {
        // expected
      }
      try {
          buffer.append(tmp, 0, -1);
        fail("IndexOutOfBoundsException should have been thrown");
      } catch (IndexOutOfBoundsException ex) {
        // expected
      }
      try {
          buffer.append(tmp, 0, 8);
        fail("IndexOutOfBoundsException should have been thrown");
      } catch (IndexOutOfBoundsException ex) {
        // expected
      }
      try {
          buffer.append(tmp, 10, Integer.MAX_VALUE);
        fail("IndexOutOfBoundsException should have been thrown");
      } catch (IndexOutOfBoundsException ex) {
        // expected
      }
      try {
          buffer.append(tmp, 2, 4);
        fail("IndexOutOfBoundsException should have been thrown");
      } catch (IndexOutOfBoundsException ex) {
        // expected
      }
    }
View Full Code Here

Examples of org.apache.http.util.CharArrayBuffer

        // expected
      }
    }

    public void testSetLength() throws Exception {
      CharArrayBuffer buffer = new CharArrayBuffer(4);
      buffer.setLength(2);
      assertEquals(2, buffer.length());
    }
View Full Code Here

Examples of org.apache.http.util.CharArrayBuffer

      buffer.setLength(2);
      assertEquals(2, buffer.length());
    }
   
    public void testSetInvalidLength() throws Exception {
      CharArrayBuffer buffer = new CharArrayBuffer(4);
      try {
          buffer.setLength(-2);
        fail("IndexOutOfBoundsException should have been thrown");
      } catch (IndexOutOfBoundsException ex) {
        // expected
      }
      try {
          buffer.setLength(200);
        fail("IndexOutOfBoundsException should have been thrown");
      } catch (IndexOutOfBoundsException ex) {
        // expected
      }
    }
View Full Code Here

Examples of org.apache.http.util.CharArrayBuffer

        // expected
      }
    }

    public void testEnsureCapacity() throws Exception {
        CharArrayBuffer buffer = new CharArrayBuffer(4);
        buffer.ensureCapacity(2);
        assertEquals(4, buffer.capacity());
        buffer.ensureCapacity(8);
        assertEquals(8, buffer.capacity());
    }
View Full Code Here

Examples of org.apache.http.util.CharArrayBuffer

        buffer.ensureCapacity(8);
        assertEquals(8, buffer.capacity());
    }

    public void testIndexOf() {
        CharArrayBuffer buffer = new CharArrayBuffer(16);
        buffer.append("name: value");
        assertEquals(4, buffer.indexOf(':'));
        assertEquals(-1, buffer.indexOf(','));
        assertEquals(4, buffer.indexOf(':', -1, 11));
        assertEquals(4, buffer.indexOf(':', 0, 1000));
        assertEquals(-1, buffer.indexOf(':', 2, 1));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.