WriterTestpublic class WriterTest extends TestCase
Methods Summary |
---|
public void | test_appendChar()
char testChar = ' ";
MockWriter writer = new MockWriter(20);
writer.append(testChar);
assertEquals(String.valueOf(testChar), String.valueOf(writer
.getContents()));
writer.close();
Writer tobj = new Support_ASimpleWriter(2);
tobj.append('a");
tobj.append('b");
assertEquals("Wrong stuff written!", "ab", tobj.toString());
try {
tobj.append('c");
fail("IOException not thrown!");
} catch (IOException e) {
// expected
}
| public void | test_appendCharSequence()
String testString = "My Test String";
MockWriter writer = new MockWriter(20);
writer.append(testString);
assertEquals(testString, String.valueOf(writer.getContents()));
writer.close();
Writer tobj = new Support_ASimpleWriter(20);
tobj.append(testString);
assertEquals("Wrong stuff written!", testString, tobj.toString());
try {
tobj.append(testString);
fail("IOException not thrown!");
} catch (IOException e) {
// expected
}
| public void | test_appendCharSequenceIntInt()
String testString = "My Test String";
MockWriter writer = new MockWriter(20);
writer.append(testString, 1, 3);
assertEquals(testString.substring(1, 3), String.valueOf(writer
.getContents()));
writer.close();
Writer tobj = new Support_ASimpleWriter(21);
testString = "0123456789abcdefghijABCDEFGHIJ";
tobj.append(testString, 0, 5);
assertEquals("Wrong stuff written!", "01234", tobj.toString());
tobj.append(testString, 10, 15);
assertEquals("Wrong stuff written!", "01234abcde", tobj.toString());
tobj.append(testString, 20, 30);
assertEquals("Wrong stuff written!", "01234abcdeABCDEFGHIJ", tobj.toString());
try {
tobj.append(testString, 30, 31);
fail("IndexOutOfBoundsException not thrown!");
} catch (IndexOutOfBoundsException e) {
// expected
}
tobj.append(testString, 20, 21); // Just fill the writer to its limit!
try {
tobj.append(testString, 29, 30);
fail("IOException not thrown!");
} catch (IOException e) {
// expected
}
| public void | test_appendCharSequenceIntInt_Exception()
String testString = "My Test String";
Writer tobj = new Support_ASimpleWriter(21);
try {
tobj.append(testString, 30, 31);
fail("IndexOutOfBoundsException not thrown!");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
tobj.append(testString, -1, 1);
fail("IndexOutOfBoundsException not thrown!");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
tobj.append(testString, 0, -1);
fail("IndexOutOfBoundsException not thrown!");
} catch (IndexOutOfBoundsException e) {
// expected
}
| public void | test_write$C()
Writer tobj = new Support_ASimpleWriter(21);
tobj.write("01234".toCharArray());
assertEquals("Wrong stuff written!", "01234", tobj.toString());
tobj.write("abcde".toCharArray());
assertEquals("Wrong stuff written!", "01234abcde", tobj.toString());
tobj.write("ABCDEFGHIJ".toCharArray());
assertEquals("Wrong stuff written!", "01234abcdeABCDEFGHIJ", tobj.toString());
tobj.write("z".toCharArray()); // Just fill the writer to its limit!
try {
tobj.write("LES JEUX SONT FAITS".toCharArray());
fail("IOException not thrown!");
} catch (IOException e) {
// expected
}
| public void | test_writeI()
Writer tobj = new Support_ASimpleWriter(2);
tobj.write('a");
tobj.write('b");
assertEquals("Wrong stuff written!", "ab", tobj.toString());
try {
tobj.write('c");
fail("IOException not thrown!");
} catch (IOException e) {
// expected
}
| public void | test_writeLjava_lang_String()
Writer tobj = new Support_ASimpleWriter(21);
tobj.write("01234");
assertEquals("Wrong stuff written!", "01234", tobj.toString());
tobj.write("abcde");
assertEquals("Wrong stuff written!", "01234abcde", tobj.toString());
tobj.write("ABCDEFGHIJ");
assertEquals("Wrong stuff written!", "01234abcdeABCDEFGHIJ", tobj.toString());
tobj.write("z"); // Just fill the writer to its limit!
try {
tobj.write("LES JEUX SONT FAITS");
fail("IOException not thrown!");
} catch (IOException e) {
// expected
}
| public void | test_writeLjava_lang_StringII()
String testString;
Writer tobj = new Support_ASimpleWriter(21);
testString = "0123456789abcdefghijABCDEFGHIJ";
tobj.write(testString, 0, 5);
assertEquals("Wrong stuff written!", "01234", tobj.toString());
tobj.write(testString, 10, 5);
assertEquals("Wrong stuff written!", "01234abcde", tobj.toString());
tobj.write(testString, 20, 10);
assertEquals("Wrong stuff written!", "01234abcdeABCDEFGHIJ", tobj.toString());
try {
tobj.write(testString, 30, 1);
fail("IndexOutOfBoundsException not thrown!");
} catch (IndexOutOfBoundsException e) {
// expected
}
tobj.write(testString, 20, 1); // Just fill the writer to its limit!
try {
tobj.write(testString, 29, 1);
fail("IOException not thrown!");
} catch (IOException e) {
// expected
}
| public void | test_writeLjava_lang_StringII_Exception()
String testString = "My Test String";
Writer tobj = new Support_ASimpleWriter(21);
try {
tobj.write(testString, 30, 31);
fail("IndexOutOfBoundsException not thrown!");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
tobj.write(testString, -1, 1);
fail("IndexOutOfBoundsException not thrown!");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
tobj.write(testString, 0, -1);
fail("IndexOutOfBoundsException not thrown!");
} catch (IndexOutOfBoundsException e) {
// expected
}
|
|