예제 #1
0
        public void HexToBitsTest()
        {
            BitArray[] hexBits = new BitArray[16];
            hexBits[0]  = new BitArray(new bool[] { false, false, false, false });
            hexBits[1]  = new BitArray(new bool[] { false, false, false, true });
            hexBits[2]  = new BitArray(new bool[] { false, false, true, false });
            hexBits[3]  = new BitArray(new bool[] { false, false, true, true });
            hexBits[4]  = new BitArray(new bool[] { false, true, false, false });
            hexBits[5]  = new BitArray(new bool[] { false, true, false, true });
            hexBits[6]  = new BitArray(new bool[] { false, true, true, false });
            hexBits[7]  = new BitArray(new bool[] { false, true, true, true });
            hexBits[8]  = new BitArray(new bool[] { true, false, false, false });
            hexBits[9]  = new BitArray(new bool[] { true, false, false, true });
            hexBits[10] = new BitArray(new bool[] { true, false, true, false });
            hexBits[11] = new BitArray(new bool[] { true, false, true, true });
            hexBits[12] = new BitArray(new bool[] { true, true, false, false });
            hexBits[13] = new BitArray(new bool[] { true, true, false, true });
            hexBits[14] = new BitArray(new bool[] { true, true, true, false });
            hexBits[15] = new BitArray(new bool[] { true, true, true, true });

            for (int i = 0; i < 16; i++)
            {
                string   hexChar  = StringConverters.hexMap[i].ToString();
                BitArray testBits = StringConverters.HexToBits(hexChar);

                for (int j = 0; j < 4; j++)
                {
                    Assert.IsTrue(testBits[j] == hexBits[i][j]);
                }
            }
        }