コード例 #1
0
        public void Ext_UIntN_Get_Exc_LessThan2Bits_Loopback()
        {
            BVector d = new BVector();

            d.Add((uint?)0, 32);
            d.GetUIntN(1);
        }
コード例 #2
0
        public void Ext_UIntN_Get_Exc_MoreThan32Bits_Loopback()
        {
            BVector d = new BVector();

            d.Add((uint?)0, 32);
            d.GetUIntN(33);
        }
コード例 #3
0
        public void Ext_UIntN_AddGet_BitsMax_InOut()
        {
            BVector d = new BVector();
            uint?   value;
            uint?   val;
            uint?   expected;
            uint?   maxVal  = int.MaxValue;
            uint?   nullVal = null;
            byte    bits;


            // add min and max values for 2-32 bits
            for (int i = 0; i < 31; i++)
            {
                bits  = (byte)(32 - i);
                value = maxVal >> i;
                // add max
                d.Add(value, bits);

                // add null
                d.Add(nullVal, bits);
            }

            // add min and max values for 2-32 bits seperated by 1 bit
            d.Add1(false);
            for (int i = 0; i < 31; i++)
            {
                bits  = (byte)(32 - i);
                value = maxVal >> i;
                // add max
                d.Add(value, bits);
                d.Add1(false);

                // add null
                d.Add(nullVal, bits);
                d.Add1(false);
            }

            BVector d2 = new BVector(d.ToBytes());

            // get min and max values for 2-32 bits
            for (int i = 0; i < 31; i++)
            {
                bits = (byte)(32 - i);

                // get max
                expected = maxVal >> i;
                val      = d2.GetUIntN(bits);
                Assert.AreEqual(expected, val);

                // get null
                expected = nullVal;
                val      = d2.GetUIntN(bits);
                Assert.AreEqual(expected, val);
            }

            // get min and max values for 2-32 bits seperated by 1 bit
            Assert.AreEqual(false, d2.Get1());
            for (int i = 0; i < 31; i++)
            {
                bits = (byte)(32 - i);

                // get max
                expected = maxVal >> i;
                val      = d2.GetUIntN(bits);
                Assert.AreEqual(expected, val);
                Assert.AreEqual(false, d2.Get1());

                // get min
                expected = nullVal;
                val      = d2.GetUIntN(bits);
                Assert.AreEqual(expected, val);
                Assert.AreEqual(false, d2.Get1());
            }
        }