示例#1
0
        public void HuffmanTreeLeaf()
        {
            HuffmanTreeLeaf<int> a = new HuffmanTreeLeaf<int>(5, 9);
            Assert.AreEqual(9, a.Frequency);
            Assert.AreEqual(5, a.Symbol);

            HuffmanTreeLeaf<int> b = new HuffmanTreeLeaf<int>(7, 21);
            Assert.AreEqual(21, b.Frequency);
            Assert.AreEqual(7, b.Symbol);
        }
示例#2
0
        public void HuffmanTreeInternal()
        {
            HuffmanTreeLeaf<int> a = new HuffmanTreeLeaf<int>(5, 9);
            HuffmanTreeLeaf<int> b = new HuffmanTreeLeaf<int>(7, 21);
            HuffmanTreeLeaf<int> c = new HuffmanTreeLeaf<int>(2, 125);

            HuffmanTreeInternalNode<int> i1 = new HuffmanTreeInternalNode<int>(a, b);
            Assert.AreEqual(30, i1.Frequency);

            HuffmanTreeInternalNode<int> i2 = new HuffmanTreeInternalNode<int>(c, i1);
            Assert.AreEqual(155, i2.Frequency);
        }
示例#3
0
        public void HuffmanTreeCast()
        {
            HuffmanTreeLeaf<int> a = new HuffmanTreeLeaf<int>(5, 9);
            HuffmanTreeLeaf<int> b = new HuffmanTreeLeaf<int>(7, 21);
            HuffmanTreeInternalNode<int> i1 = new HuffmanTreeInternalNode<int>(a, b);

            HuffmanTree<int> castA = a as HuffmanTree<int>;
            Assert.NotNull(castA);
            Assert.AreEqual(9, castA.Frequency);

            HuffmanTree<int> castI1 = i1 as HuffmanTree<int>;
            Assert.NotNull(castI1);
            Assert.AreEqual(30, castI1.Frequency);
        }
示例#4
0
 public void HuffmanTreeRightLeafNull()
 {
     HuffmanTreeLeaf<int> a = new HuffmanTreeLeaf<int>(5, 9);
     HuffmanTreeInternalNode<int> i1 = new HuffmanTreeInternalNode<int>(a, null);
 }
示例#5
0
 public void HuffmanTreeNegativeFrequency()
 {
     HuffmanTreeLeaf<int> a = new HuffmanTreeLeaf<int>(5, -1);
 }
示例#6
0
 public void HuffmanTreeLeftLeafNull()
 {
     HuffmanTreeLeaf<int> a = new HuffmanTreeLeaf<int>(5, 9);
     HuffmanTreeInternalNode<int> i1 = new HuffmanTreeInternalNode<int>(null, a);
 }