예제 #1
0
        public void Should_SerializeInt2()
        {
            Int2 value = Int2.MaxValue; // range -1 to 1

            Assert.AreEqual(false, value._sign);
            Assert.AreEqual(1, value.GetBit(0));
            Assert.AreEqual(0, value.GetBit(1));
            Assert.AreEqual(new Bit[] { 1, 0 }, value.GetBits());

            value = Int2.MinValue;
            Assert.AreEqual(true, value._sign);
            Assert.AreEqual(1, value.GetBit(0));
            Assert.AreEqual(1, value.GetBit(1));
            Assert.AreEqual(new Bit[] { 1, 1 }, value.GetBits());

            // test overflow
            value = (Int2)7;
            Assert.AreEqual(1, value);
            Assert.AreEqual(false, value._sign);
            Assert.AreEqual(1, value.GetBit(0));
            Assert.AreEqual(0, value.GetBit(1));
            Assert.AreEqual(new Bit[] { 1, 0 }, value.GetBits());
        }