public static void test(byte[] ba)
{
int offset = 47;
int length = 900;
ByteBuffer b = ByteBuffer.Wrap(ba, offset, length);
Show(0, b);
ck(b, b.Capacity, ba.Length);
ck(b, b.Position, offset);
ck(b, b.Limit, offset + length);
// The offset must be non-negative and no larger than <array.length>.
tryCatch(ba, typeof(ArgumentOutOfRangeException), () =>
{
ByteBuffer.Wrap(ba, -1, ba.Length);
});
tryCatch(ba, typeof(ArgumentOutOfRangeException), () =>
{
ByteBuffer.Wrap(ba, ba.Length + 1, ba.Length);
});
tryCatch(ba, typeof(ArgumentOutOfRangeException), () =>
{
ByteBuffer.Wrap(ba, 0, -1);
});
tryCatch(ba, typeof(ArgumentOutOfRangeException), () =>
{
ByteBuffer.Wrap(ba, 0, ba.Length + 1);
});
// A NullPointerException will be thrown if the array is null.
tryCatch(ba, typeof(NullReferenceException), () =>
{
ByteBuffer.Wrap((byte[])null, 0, 5);
});
tryCatch(ba, typeof(NullReferenceException), () =>
{
ByteBuffer.Wrap((byte[])null);
});
}