Пример #1
0
        static void Main(string[] args)
        {
            sbyte word = 0b00001100;

            Console.WriteLine(Convert.ToString(word, 2));
            Console.WriteLine(word.GetBit(7));
            //for (int i = 0; i <= 31; ++i)
            //    Console.WriteLine(word.GetBit(i));
            Console.WriteLine(Convert.ToString(word.SetBit(1, 7), 2));
            Console.WriteLine(word.GetBit(7));
        }
Пример #2
0
        public void GetBit0Test_sbyte()
        {
            sbyte w        = 0b01001010;
            bool  expected = false;
            bool  actual   = w.GetBit(0);

            Assert.AreEqual(expected, actual);
        }
Пример #3
0
        public void GetBitTest_sbyte()
        {
            sbyte w        = 0b01001010;
            bool  expected = true;
            bool  actual   = w.GetBit(3);

            Assert.AreEqual(expected, actual);
        }
Пример #4
0
        public void GetBit_PositioLessThan0_Exeption_Test_sbyte()
        {
            sbyte w = -100;

            Assert.ThrowsException <ArgumentOutOfRangeException>(() => w.GetBit(-1));
        }
Пример #5
0
        public void GetBit_PositioGreaterThanSize_Exeption_Test_sbyte()
        {
            sbyte w = 0b01001010;

            Assert.ThrowsException <ArgumentOutOfRangeException>(() => w.GetBit(8));
        }