static void ClipTest(uint[] b, int vals, int bits, uint[] comp, int compsize) { int bytes; byte *buffer; Ogg.oggpack_reset(ref o); for (int i = 0; i < vals; i++) { Ogg.oggpack_write(ref o, b[i], bits > 0 ? bits : iLog(b[i])); } buffer = Ogg.oggpack_get_buffer(ref o); bytes = Ogg.oggpack_bytes(ref o); if (bytes != compsize) { throw new Exception("wrong number of bytes!"); } for (int i = 0; i < bytes; i++) { if (buffer[i] != comp[i]) { for (int j = 0; j < bytes; j++) { Console.WriteLine(buffer[j] + " , " + comp[j]); } throw new Exception("wrote incorrect value!"); } } Ogg.oggpack_readinit(ref r, buffer, bytes); for (int i = 0; i < vals; i++) { int tbit = bits > 0 ? bits : iLog(b[i]); if (Ogg.oggpack_look(ref r, tbit) == -1) { throw new Exception("out of data!"); } if (Ogg.oggpack_look(ref r, tbit) != (b[i] & mask[tbit])) { throw new Exception("looked at incorrect value!"); } if (tbit == 1) { if (Ogg.oggpack_look1(ref r) != (b[i] & mask[tbit])) { throw new Exception("looked at single bit incorrect value!"); } } if (tbit == 1) { if (Ogg.oggpack_read1(ref r) != (b[i] & mask[tbit])) { throw new Exception("read incorrect single bit value!"); } } else if (Ogg.oggpack_read(ref r, tbit) != (b[i] & mask[tbit])) { throw new Exception("read incorrect value!"); } } if (Ogg.oggpack_bytes(ref r) != bytes) { throw new Exception("leftover bytes after read!"); } }