package com.wizzardo.epoll.readable;

import com.wizzardo.epoll.ByteBufferWrapper;
import org.junit.Test;

import java.nio.ByteBuffer;

import static org.junit.Assert.*;

/**
 * Created by wizzardo on 24.04.16.
 */
public class ReadableByteBufferTest {

    @Test
    public void test_1() {
        ByteBuffer buffer = ByteBuffer.allocateDirect(256);
        ReadableByteBuffer readable = new ReadableByteBuffer(buffer);

        assertSame(buffer, readable.getByteBuffer(null).buffer());
    }

    @Test
    public void test_2() {
        ByteBuffer buffer = ByteBuffer.allocateDirect(256);
        ReadableByteBuffer readable = new ReadableByteBuffer(buffer);
        assertEquals(256, readable.read(readable.getByteBuffer(null).buffer()));
    }

}
@@ -278,17 +278,26 @@
 id test_
-1
+sameBuffer
 () %7B%0A   
@@ -529,17 +529,23 @@
 id test_
-2
+readAll
 () %7B%0A   
@@ -759,9 +759,1062 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void test_read_into_heap_bb() %7B%0A        ByteBuffer buffer = ByteBuffer.allocateDirect(256);%0A        for (int i = 0; i %3C 256; i++) %7B%0A            buffer.put((byte) i);%0A        %7D%0A        ReadableByteBuffer readable = new ReadableByteBuffer(buffer);%0A%0A        ByteBuffer b = ByteBuffer.allocate(256);%0A        assertEquals(256, readable.read(b));%0A        assertEquals(256, b.position());%0A        b.flip();%0A        for (int i = 0; i %3C 256; i++) %7B%0A            assertEquals((byte) i, b.get());%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void test_read_into_direct_bb() %7B%0A        ByteBuffer buffer = ByteBuffer.allocateDirect(256);%0A        for (int i = 0; i %3C 256; i++) %7B%0A            buffer.put((byte) i);%0A        %7D%0A        ReadableByteBuffer readable = new ReadableByteBuffer(buffer);%0A%0A        ByteBuffer b = ByteBuffer.allocateDirect(256);%0A        assertEquals(256, readable.read(b));%0A        assertEquals(256, b.position());%0A        b.flip();%0A        for (int i = 0; i %3C 256; i++) %7B%0A            assertEquals((byte) i, b.get());%0A        %7D%0A    %7D%0A
 %7D

add tests for reading into another buffer