Exemple #1
0
        public void TestUnpack()
        {
            int[] data = new int[] {
                BitPackage.Pack4bits(0, 1, 2, 3, 4, 5, 6, 7),
                BitPackage.Pack4bits(8, 9, 10, 11, 12, 13, 14, 15)
            };

            BitPackage pkg = new BitPackage(
                BitPackage.INDEX_SHIFT_4BITS,
                BitPackage.SHIFT_MASK_4BITS,
                BitPackage.BIT_SHIFT_4BITS,
                BitPackage.UNIT_MASK_4BITS,
                data);

            for (int i = 0; i < 16; i++)
            {
                int n = pkg.Unpack(i);
                Assert.Equal(n, i);
            }
        }
        public void ShouldUnpackCorrectly()
        {
            var data = new int[]
            {
                BitPackage.Pack4bits(0, 1, 2, 3, 4, 5, 6, 7),
                BitPackage.Pack4bits(8, 9, 10, 11, 12, 13, 14, 15)
            };

            var package = new BitPackage(
                BitPackage.IndexShift4Bits,
                BitPackage.ShiftMask4Bits,
                BitPackage.BitShift4Bits,
                BitPackage.UnitMask4Bits,
                data);

            for (int i = 0; i < 16; i++)
            {
                int actual = package.Unpack(i);
                Assert.Equal(actual, i);
            }
        }
Exemple #3
0
 public int GetClass(byte b)
 {
     return(classTable.Unpack((int)b));
 }