Line | |
---|
1 | package org.armedbear.lisp; |
---|
2 | |
---|
3 | import static org.junit.Assert.*; |
---|
4 | |
---|
5 | import org.junit.Test; |
---|
6 | |
---|
7 | public class SeekableStringWriterTest |
---|
8 | { |
---|
9 | @Test |
---|
10 | public void writeAndSeek() { |
---|
11 | SeekableStringWriter writer = new SeekableStringWriter(); |
---|
12 | String buf = "sdf"; |
---|
13 | writer.append('a').append(buf).append(buf, 1, 2); |
---|
14 | assertEquals("asdfd", writer.toString()); |
---|
15 | writer.seek(0); |
---|
16 | writer.append("meow"); |
---|
17 | assertEquals("meowd", writer.toString()); |
---|
18 | } |
---|
19 | |
---|
20 | @Test |
---|
21 | public void writeAndClear() { |
---|
22 | SeekableStringWriter writer = new SeekableStringWriter(); |
---|
23 | String buf1 = "empus"; |
---|
24 | String buf2 = " fugit"; |
---|
25 | writer.append('t').append(buf1).append(buf2, 1, 7); |
---|
26 | assertEquals("tempus fugit", writer.toString()); |
---|
27 | String result = writer.toStringAndClear(); |
---|
28 | assertEquals("tempus fugit", result); |
---|
29 | assertEquals("", writer.toString()); |
---|
30 | } |
---|
31 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.