mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
parent
2d73403b9a
commit
38d3bf1c63
|
@ -32,7 +32,8 @@ class TByteBufferImpl extends TByteBuffer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TByteBuffer slice() {
|
public TByteBuffer slice() {
|
||||||
return new TByteBufferImpl(position, limit - position, array, 0, limit - position, direct, readOnly);
|
return new TByteBufferImpl(position + start, limit - position, array, 0, limit - position,
|
||||||
|
direct, readOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -17,6 +17,7 @@ package org.teavm.classlib.java.nio;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.hamcrest.CoreMatchers.sameInstance;
|
import static org.hamcrest.CoreMatchers.sameInstance;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
import java.nio.BufferOverflowException;
|
import java.nio.BufferOverflowException;
|
||||||
|
@ -153,6 +154,18 @@ public class ByteBufferTest {
|
||||||
assertThat(slice.get(1), is((byte) 25));
|
assertThat(slice.get(1), is((byte) 25));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void sliceOfSlice() {
|
||||||
|
ByteBuffer buffer = ByteBuffer.allocate(100);
|
||||||
|
buffer.put(new byte[10]);
|
||||||
|
ByteBuffer slice1 = buffer.slice();
|
||||||
|
slice1.put(new byte[15]);
|
||||||
|
ByteBuffer slice2 = slice1.slice();
|
||||||
|
|
||||||
|
assertEquals(25, slice2.arrayOffset());
|
||||||
|
assertEquals(75, slice2.capacity());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void slicePropertiesSameWithOriginal() {
|
public void slicePropertiesSameWithOriginal() {
|
||||||
ByteBuffer buffer = ByteBuffer.allocate(100).asReadOnlyBuffer().slice();
|
ByteBuffer buffer = ByteBuffer.allocate(100).asReadOnlyBuffer().slice();
|
||||||
|
|
|
@ -17,6 +17,7 @@ package org.teavm.classlib.java.nio;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.hamcrest.CoreMatchers.sameInstance;
|
import static org.hamcrest.CoreMatchers.sameInstance;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
import java.nio.BufferOverflowException;
|
import java.nio.BufferOverflowException;
|
||||||
|
@ -132,6 +133,19 @@ public class IntBufferTest {
|
||||||
assertThat(slice.get(1), is(25));
|
assertThat(slice.get(1), is(25));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void sliceOfSlice() {
|
||||||
|
var buffer = IntBuffer.allocate(100);
|
||||||
|
buffer.put(new int[10]);
|
||||||
|
var slice1 = buffer.slice();
|
||||||
|
slice1.put(new int[15]);
|
||||||
|
var slice2 = slice1.slice();
|
||||||
|
|
||||||
|
assertEquals(25, slice2.arrayOffset());
|
||||||
|
assertEquals(75, slice2.capacity());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void slicePropertiesSameWithOriginal() {
|
public void slicePropertiesSameWithOriginal() {
|
||||||
IntBuffer buffer = IntBuffer.allocate(100).asReadOnlyBuffer().slice();
|
IntBuffer buffer = IntBuffer.allocate(100).asReadOnlyBuffer().slice();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user