This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tdd.huffman; | |
import com.google.common.collect.ImmutableList; | |
import lombok.EqualsAndHashCode; | |
import lombok.Getter; | |
import lombok.Value; | |
import java.util.List; | |
import java.util.function.Consumer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
@Test | |
void shouldCompressAndDecompress() throws IOException { | |
whenCompressingData(); | |
thenDataIsCompressed(); | |
thenCompressedDataShouldBeCorrectlyDecompressed(); | |
andTheCompressionRatioIsPrintedOut(); | |
} | |
private void andTheCompressionRatioIsPrintedOut() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tdd.huffman; | |
import org.junit.jupiter.api.Test; | |
import java.io.ByteArrayInputStream; | |
import java.io.ByteArrayOutputStream; | |
import java.io.IOException; | |
import static org.assertj.core.api.Assertions.assertThat; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tdd.huffman; | |
import javax.swing.plaf.IconUIResource; | |
public class HuffmanTreeTraverser { | |
private final HuffmanTree huffmanTree; | |
private BinaryTree<Byte> cursor; | |
public HuffmanTreeTraverser(HuffmanTree huffmanTree) { | |
this.huffmanTree = huffmanTree; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tdd.huffman; | |
import org.junit.jupiter.api.Test; | |
import static org.assertj.core.api.Assertions.assertThat; | |
import static org.junit.jupiter.api.Assertions.*; | |
class HuffmanTreeTraverserTest { | |
private HuffmanTree huffmanTree; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tdd.huffman; | |
public class HuffmanTreeTraverser { | |
private final HuffmanTree huffmanTree; | |
public HuffmanTreeTraverser(HuffmanTree huffmanTree) { | |
this.huffmanTree = huffmanTree; | |
} | |
public void traverseLeftBranch() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tdd.huffman; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.OutputStream; | |
import java.util.Optional; | |
public class HuffmanDecompressor { | |
private final HuffmanTreeDeserializer huffmanTreeDeserializer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tdd.huffman; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.OutputStream; | |
import java.util.List; | |
import java.util.Map; | |
import static tdd.huffman.Bit.one; | |
import static tdd.huffman.Bit.zero; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tdd.huffman; | |
import org.junit.jupiter.api.Test; | |
import java.io.ByteArrayInputStream; | |
import java.io.ByteArrayOutputStream; | |
import java.io.IOException; | |
import java.util.Arrays; | |
import static org.assertj.core.api.Assertions.assertThat; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tdd.huffman; | |
import org.junit.jupiter.api.Test; | |
import java.io.ByteArrayInputStream; | |
import java.io.ByteArrayOutputStream; | |
import static org.assertj.core.api.Assertions.assertThat; | |
public class HuffmanCompressionIT { |