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); }
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); }
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); }
public void HuffmanTreeRightLeafNull() { HuffmanTreeLeaf<int> a = new HuffmanTreeLeaf<int>(5, 9); HuffmanTreeInternalNode<int> i1 = new HuffmanTreeInternalNode<int>(a, null); }
public void HuffmanTreeNegativeFrequency() { HuffmanTreeLeaf<int> a = new HuffmanTreeLeaf<int>(5, -1); }
public void HuffmanTreeLeftLeafNull() { HuffmanTreeLeaf<int> a = new HuffmanTreeLeaf<int>(5, 9); HuffmanTreeInternalNode<int> i1 = new HuffmanTreeInternalNode<int>(null, a); }