Exemplo n.º 1
0
        public void EncodeTest1()
        {
            MockBitWriter io      = new MockBitWriter();
            Shannon       shannon = new Shannon(io);

            shannon.Encode(5);
            Assert.AreEqual(io.values.Count(), 8);
            Assert.AreEqual(io.values[0], false);
            Assert.AreEqual(io.values[1], false);
            Assert.AreEqual(io.values[2], false);
            Assert.AreEqual(io.values[3], false);
            Assert.AreEqual(io.values[4], false);
            Assert.AreEqual(io.values[5], true);
            Assert.AreEqual(io.values[6], false);
            Assert.AreEqual(io.values[7], true);
            io.Clear();
            shannon.Encode(5);
            Assert.AreEqual(io.values.Count(), 7);
            Assert.AreEqual(io.values[0], false);
            Assert.AreEqual(io.values[1], false);
            Assert.AreEqual(io.values[2], false);
            Assert.AreEqual(io.values[3], false);
            Assert.AreEqual(io.values[4], false);
            Assert.AreEqual(io.values[5], false);
            Assert.AreEqual(io.values[6], false);
        }
Exemplo n.º 2
0
        public void EncodeDecodeTest()
        {
            MockBitWriter io      = new MockBitWriter();
            Shannon       encoder = new Shannon(io);

            foreach (char character in "Lorem ipsum dolor sit amet consectetur adepiscig nullam")
            {
                encoder.Encode(character);
            }
            Shannon decoder = new Shannon(io);

            foreach (char character in "Lorem ipsum dolor sit amet consectetur adepiscig nullam")
            {
                Assert.AreEqual(decoder.Decode(), character);
            }
        }