Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@
*.exe
*.out
*.app
build/
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.10)
project(HuffmanCoding LANGUAGES CXX)

if(NOT CMAKE_CXX_COMPILER)
set(CMAKE_CXX_COMPILER g++)
endif()

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

add_executable(huffmanCoding huffmanCoding.cpp huffman.cpp)
add_executable(huffmanDecoding huffmanDecoding.cpp huffman.cpp)

enable_testing()

set(HUFFMAN_TEST_SCRIPT ${CMAKE_SOURCE_DIR}/tests/run_tests.sh)
add_test(
NAME huffman_roundtrip
COMMAND bash ${HUFFMAN_TEST_SCRIPT} $<TARGET_FILE:huffmanCoding> $<TARGET_FILE:huffmanDecoding>
)
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,20 @@ The programs can compress and decompress text file consisting of 128 ASCII chara

1. Open file, recreate Huffman Tree based on Huffman Encode Table;
2. Decode the file based on the tree and store it to the desired file.

## Build and test

```bash
cmake -S . -B build -DCMAKE_CXX_COMPILER=g++
cmake --build build
ctest --test-dir build --output-on-failure
```

Run manually:

```bash
./build/huffmanCoding input.txt output.huf
./build/huffmanDecoding output.huf restored.txt
```

Input is limited to 7-bit ASCII bytes (0–127). Empty files and bytes >= 128 are rejected with an error message.
Loading