Beispiel #1
0
        public void EvenTest()
        {
            var bitStore = new BitStore(4, 16);

            bitStore.Write(0, 93);
            bitStore.Write(1, 2);
            bitStore.Write(2, 1231);
            bitStore.Write(3, 1231);

            Assert.AreEqual((uint)93, bitStore.Read(0));
            Assert.AreEqual(1231, bitStore.Read(3));
        }
Beispiel #2
0
        public void SimpleTest()
        {
            var bitStore = new BitStore(6, 20);
            var maxValue = (uint)(1 << 20) - 1;

            bitStore.Write(0, 93);
            bitStore.Write(1, maxValue);
            bitStore.Write(2, 13424);

            Assert.AreEqual((uint)93, bitStore.Read(0));
            Assert.AreEqual(maxValue, bitStore.Read(1));
            Assert.AreEqual(13424, bitStore.Read(2));

            // Wipe out all of the 1s with 0s to make sure it workes.
            bitStore.Write(1, 0);
            Assert.AreEqual(0, bitStore.Read(1));
        }
Beispiel #3
0
        public void AcrossBoundary()
        {
            var bitStore = new BitStore(8, 20);
            var maxValue = (uint)(1 << 20) - 1;

            // Random writes.
            bitStore.Write(0, 93);
            bitStore.Write(5, 13424);
            bitStore.Write(2, 13424);
            bitStore.Write(1, maxValue);
            bitStore.Write(3, maxValue);
            bitStore.Write(7, 13424);
            bitStore.Write(6, 13424);
            bitStore.Write(4, 13424);

            Assert.AreEqual((uint)93, bitStore.Read(0));
            Assert.AreEqual(maxValue, bitStore.Read(1));
            Assert.AreEqual(maxValue, bitStore.Read(3));
            Assert.AreEqual(13424, bitStore.Read(4));
            Assert.AreEqual(13424, bitStore.Read(7));
            Assert.AreEqual(13424, bitStore.Read(2));
            Assert.AreEqual(13424, bitStore.Read(5));
            Assert.AreEqual(13424, bitStore.Read(6));
            Assert.AreEqual(13424, bitStore.Read(7));
            Assert.AreEqual(13424, bitStore.Read(5));
            Assert.AreEqual(13424, bitStore.Read(6));

            // Wipe out all of the 1s with 0s to make sure it workes.
            bitStore.Write(1, 0);
            Assert.AreEqual(0, bitStore.Read(1));
        }