Esempio n. 1
0
        public void WithoutMap()
        {
            var    headerCrator = new HeaderCreator();
            Header header       = headerCrator.Create(HuffmanEncodeModel.Standard, false, new Dictionary <string, HuffmanCoder.Logic.Entities.OutputValues>());

            // Expected: header size - 4 bytes, huffmanEncodeModel - 1 byte, specialSymbol - 1 byte
            Assert.AreEqual(6, header.Content.Length);
        }
Esempio n. 2
0
        public void OneDoubleSymbolInMap()
        {
            var headerCrator = new HeaderCreator();
            var map          = new Dictionary <string, HuffmanCoder.Logic.Entities.OutputValues>();

            map.Add("AA", new HuffmanCoder.Logic.Entities.OutputValues {
                Counts = 5
            });

            Header header = headerCrator.Create(HuffmanEncodeModel.Block, false, map);

            // Expected: header size - 4 bytes, huffmanEncodeModel - 1 byte, specialSymbol - 1 byte, map (AA5) - 4 bytes
            Assert.AreEqual(10, header.Content.Length);
        }
Esempio n. 3
0
        public void TwoSymbolsInMap()
        {
            var headerCrator = new HeaderCreator();
            var map          = new Dictionary <string, HuffmanCoder.Logic.Entities.OutputValues>();

            map.Add("A", new HuffmanCoder.Logic.Entities.OutputValues {
                Counts = 5
            });
            map.Add("B", new HuffmanCoder.Logic.Entities.OutputValues {
                Counts = 3
            });

            Header header = headerCrator.Create(HuffmanEncodeModel.Standard, false, map);

            // Expected: header size - 4 bytes, huffmanEncodeModel - 1 byte, specialSymbol - 1 byte, map (A5B3) - 6 bytes
            Assert.AreEqual(12, header.Content.Length);
        }
Esempio n. 4
0
        public void SingleSymbolInMarkovModel()
        {
            var headerCrator = new HeaderCreator();
            var map          = new Dictionary <string, HuffmanCoder.Logic.Entities.OutputValues>();

            map.Add("A", new HuffmanCoder.Logic.Entities.OutputValues {
                Counts = 5
            });
            map.Add("BC", new HuffmanCoder.Logic.Entities.OutputValues {
                Counts = 5
            });

            Header header = headerCrator.Create(HuffmanEncodeModel.Markov, true, map);

            // Expected: header size - 4 bytes, huffmanEncodeModel - 1 byte, specialSymbol - 1 byte, map (A5BC5) - 8 bytes
            Assert.AreEqual(13, header.Content.Length);
        }