Ejemplo n.º 1
0
        public void BitSetTest()
        {
            bool[] testCheck = new bool[32];
            uint[] result    = new uint[32];
            uint[] expected  = new uint[32];

            BitMath Local = new BitMath();

            //test
            for (int i = 0; i <= 31; i++)
            {
                result[i] = Local.BitSet(i);
            }

            int  passCount = 0;
            uint testValue = 1;

            for (int i = 0; i <= 31; i++)
            {
                expected[i] = testValue << i;
                if (result[i] == expected[i])
                {
                    passCount++;
                    testCheck[i] = true;
                }
                else
                {
                    testCheck[i] = false;
                }
            }
            Console.Write("--BitSet_Test--\n");
            for (int n = 0; n <= 31; n++)
            {
                Console.Write("i = \t");
                Console.Write(n);
                Console.Write("\t pass? = \t");
                Console.Write(testCheck[n]);
                Console.Write("\t expect = \t");
                Console.Write(expected[n]);
                if (n <= 23)
                {
                    Console.Write("\t\t\t\t result = \t");
                }
                else
                {
                    Console.Write("\t\t\t result = \t");
                }
                Console.Write(result[n]);
                Console.Write("\n");
            }
            Assert.AreEqual(passCount, 32);
        }