Exemple #1
0
        public void TestFull()
        {
            Encoder.BlockCode(model);
            Encoder.SWCode(model);
            Encoder.SFCode(model);
            Encoder.Huffman(model);

            model.CalculateValues();

            //test Kraft
            Assert.AreEqual(1, model.ShannonWeaver.Kraft);
            Assert.AreEqual(1, model.ShannonFano.Kraft);
            Assert.AreEqual(1, model.Huffman.Kraft);

            Assert.AreEqual(3, model.BlockCode.AverageLength);
        }
Exemple #2
0
        public void TestBlockCode()
        {
            Encoder.BlockCode(model);
            var block = model.BlockCode;

            Assert.IsNotNull(block);

            var codes = block.Code;

            codes.TryGetValue('A', out string A);
            Assert.AreEqual("000", A);
            codes.TryGetValue('B', out string B);
            Assert.AreEqual("001", B);
            codes.TryGetValue('C', out string C);
            Assert.AreEqual("010", C);
            codes.TryGetValue('D', out string D);
            Assert.AreEqual("011", D);
            codes.TryGetValue('E', out string E);
            Assert.AreEqual("100", E);
            codes.TryGetValue('F', out string F);
            Assert.AreEqual("101", F);
            codes.TryGetValue('G', out string G);
            Assert.AreEqual("110", G);
        }