Ejemplo n.º 1
0
 internal static void ck(BufferN b, long got, long expected)
 {
     if (expected != got)
     {
         fail(b, expected, got);
     }
 }
Ejemplo n.º 2
0
        internal static void fail(BufferN b,
                                  String expected, char expectedChar,
                                  String got, char gotChar)
        {
            if (b is ByteBufferN)
            {
                var bb = (ByteBufferN)b;
                int n  = Math.Min(16, bb.limit());
                for (int i = 0; i < n; i++)
                {
                    outt.print(" " + Integer.toHexString(bb.get(i) & 0xff));
                }
                outt.println();
            }

            /*if (b is CharBuffer) {
             * CharBuffer bb = (CharBuffer)b;
             * int n = Math.min(16, bb.limit());
             * for (int i = 0; i < n; i++)
             *  outt.print(" " + Integer.toHexString(bb.get(i) & 0xffff));
             * outt.println();
             * }*/
            throw new RuntimeException(toString(b)
                                       + ": Expected '" + expectedChar + "'=0x"
                                       + expected
                                       + ", got '" + gotChar + "'=0x"
                                       + got);
        }
Ejemplo n.º 3
0
 internal static void ck(BufferN b, bool cond)
 {
     if (!cond)
     {
         fail("Condition failed", b);
     }
 }
Ejemplo n.º 4
0
 internal static void show(int level, BufferN b)
 {
     for (int i = 0; i < level; i++)
     {
         outt.print("  ");
     }
     outt.println(toString(b) + " " + Integer.toHexString(b.GetHashCode()));
 }
Ejemplo n.º 5
0
 internal static String toString(BufferN b)
 {
     return(b.GetType().Name
            + "[pos=" + b.position()
            + " lim=" + b.limit()
            + " cap=" + b.capacity()
            + "]");
 }
Ejemplo n.º 6
0
 private static void checkInvalidMarkException(BufferN b)
 {
     tryCatch(b, typeof(InvalidMarkException), () =>
     {
         b.mark();
         compact(b);
         b.reset();
     });
 }
Ejemplo n.º 7
0
 internal static void ck(BufferN b, double got, double expected)
 {
     if (expected != got)
     {
         fail(b,
              Double.toString(expected), (char)expected,
              Double.toString(got), (char)got);
     }
 }
Ejemplo n.º 8
0
 internal static void ck(BufferN b, float got, float expected)
 {
     if (expected != got)
     {
         fail(b,
              Float.toString(expected), (char)expected,
              Float.toString(got), (char)got);
     }
 }
Ejemplo n.º 9
0
 private static void compact(BufferN b)
 {
     /*
      * try {
      * Class<?> cl = b.getClass();
      * Method m = cl.getDeclaredMethod("compact");
      * m.setAccessible(true);
      * m.invoke(b);
      * } catch (Exception e) {
      * fail(e.getMessage(), b);
      * }
      */
     throw new NotImplementedException();
 }
Ejemplo n.º 10
0
        private static void tryCatch(BufferN b, Type ex, Action thunk)
        {
            bool caught = false;

            try
            {
                thunk();
            }
            catch (Exception x)
            {
                if (ex.IsAssignableFrom(x.GetType()))
                {
                    caught = true;
                }
                else
                {
                    fail(x.Message + " not expected");
                }
            }
            if (!caught)
            {
                fail(ex.Name + " not thrown", b);
            }
        }
Ejemplo n.º 11
0
 internal static void fail(String s, BufferN b, BufferN b2)
 {
     throw new RuntimeException(s + ": "
                                + toString(b) + ", " + toString(b2));
 }
Ejemplo n.º 12
0
 internal static void fail(BufferN b, long expected, long got)
 {
     fail(b,
          Long.toHexString(expected), (char)expected,
          Long.toHexString(got), (char)got);
 }