package org.osgl.util;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.osgl.TestBase;

public class SBufferTest extends TestBase {

    @Before
    public void reset() {
        System.out.println("reset...");

        S.buffer().reset();
    }

    @Test
    public void itShallNotReuseUnconsumedBuffer() {
        S.Buffer sb = S.buffer("abc");
        S.Buffer sb2 = S.buffer("123");
        assertNotSame(sb, sb2);
    }

    @Test
    @Ignore
    //TODO: fix me!!
    public void itShallReuseConsumedBuffer() {
        S.Buffer sb = S.buffer("abc");
        eq("abc", sb.toString());
        S.Buffer sb2 = S.buffer("123");
        assertSame(sb, sb2);
        eq("123", sb2.toString());
        assertSame(sb, sb2);
    }

    @Test
    public void testPrepend() {
        S.Buffer sb = S.newBuffer("abc");
        sb.prepend("1234");
        eq("1234abc", sb.toString());
        sb = S.newBuffer("abc");
        sb.prepend(true);
        eq("trueabc", sb.toString());
        sb = S.newBuffer("abc");
        sb.prepend(100);
        eq("100abc", sb.toString());
        sb = S.newBuffer("abc");
        sb.prepend(Long.MAX_VALUE);
        eq(S.builder(Long.MAX_VALUE).append("abc").toString(), sb.toString());
        sb = S.newBuffer("abc");
        sb.prepend(3.3f);
        eq("3.3abc", sb.toString());
    }

}

@@ -21,58 +21,8 @@
 l;%0A%0A
-import org.junit.Before;%0Aimport org.junit.Ignore;%0A
 impo
@@ -116,122 +116,8 @@
  %7B%0A%0A
-    @Before%0A    public void reset() %7B%0A        System.out.println(%22reset...%22);%0A%0A        S.buffer().reset();%0A    %7D%0A%0A
     
@@ -293,53 +293,152 @@
     
-%7D%0A%0A    @Test%0A    @Ignore%0A    //TODO: fix me!!
+    // we need to consume the buffer to avoid%0A        // break of next test case%0A        sb.toString();%0A        sb2.toString();%0A    %7D%0A%0A    @Test
 %0A   

fix SBufferTest case