Exemplo n.º 1
0
        public static void Test()
        {
            TestAllocate();
            test(0, LongBuffer.Allocate(7 * 1024), false);
            test(0, LongBuffer.Wrap(new long[7 * 1024], 0, 7 * 1024), false);
            test(new long[1024]);

            callReset(LongBuffer.Allocate(10));
            putBuffer();
        }
Exemplo n.º 2
0
        public static void test(long[] ba)
        {
            int        offset = 47;
            int        length = 900;
            LongBuffer b      = LongBuffer.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), () =>
            {
                LongBuffer.Wrap(ba, -1, ba.Length);
            });
            tryCatch(ba, typeof(ArgumentOutOfRangeException), () =>
            {
                LongBuffer.Wrap(ba, ba.Length + 1, ba.Length);
            });
            tryCatch(ba, typeof(ArgumentOutOfRangeException), () =>
            {
                LongBuffer.Wrap(ba, 0, -1);
            });
            tryCatch(ba, typeof(ArgumentOutOfRangeException), () =>
            {
                LongBuffer.Wrap(ba, 0, ba.Length + 1);
            });

            // A NullPointerException will be thrown if the array is null.
            tryCatch(ba, typeof(NullReferenceException), () =>
            {
                LongBuffer.Wrap((long[])null, 0, 5);
            });
            tryCatch(ba, typeof(NullReferenceException), () =>
            {
                LongBuffer.Wrap((long[])null);
            });
        }
Exemplo n.º 3
0
 private static void tryCatch(long[] t, Type ex, Action thunk)
 {
     tryCatch(LongBuffer.Wrap(t), ex, thunk);
 }