(t *testing.T)
| 29 | } |
| 30 | |
| 31 | func TestHuffman(t *testing.T) { |
| 32 | messages := []string{ |
| 33 | "hello world \U0001F600", |
| 34 | "colorless green ideas sleep furiously", |
| 35 | "the quick brown fox jumps over the lazy dog", |
| 36 | `Lorem ipsum dolor sit amet, consectetur adipiscing elit, |
| 37 | sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. |
| 38 | Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut |
| 39 | aliquip ex ea commodo consequat.`, |
| 40 | } |
| 41 | |
| 42 | for _, message := range messages { |
| 43 | t.Run("huffman: "+message, func(t *testing.T) { |
| 44 | tree, _ := compression.HuffTree(SymbolCountOrd(message)) |
| 45 | codes := make(map[rune][]bool) |
| 46 | compression.HuffEncoding(tree, nil, codes) |
| 47 | messageCoded := compression.HuffEncode(codes, message) |
| 48 | messageHuffDecoded := compression.HuffDecode(tree, tree, messageCoded, "") |
| 49 | if messageHuffDecoded != message { |
| 50 | t.Errorf("got: %q\nbut expected: %q", messageHuffDecoded, message) |
| 51 | |
| 52 | } |
| 53 | }) |
| 54 | } |
| 55 | } |
nothing calls this directly
no test coverage detected