source: trunk/abcl/test/src/org/armedbear/lisp/SeekableStringWriterTest.java

Last change on this file was 14976, checked in by Mark Evenson, 8 years ago

Fix CL:GET-OUTPUT-STREAM-STRING to reset underlying buffer

The contribution on supporting FILE-POSITION for string streams in
<http://abcl.org/trac/changeset/14857> did not reset the underlying
buffer on reads via CL:GET-OUTPUT-STREAM-STRING as required by ANSI.

Fixes <http://abcl.org/trac/ticket/439>

File size: 867 bytes
Line 
1package org.armedbear.lisp;
2
3import static org.junit.Assert.*;
4
5import org.junit.Test;
6
7public 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.