-
Notifications
You must be signed in to change notification settings - Fork 1
🧪 [Missing Backreference Bounds Test in LZ77] #280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1 @@ | ||||||||
| make -j$(nproc) check TESTS="test_compression_lz77 test_compression_lz77_edge_cases" | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The script is missing a shebang (e.g.,
Suggested change
|
||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,6 +118,32 @@ int main() { | |
| std::cout << "Passed.\n"; | ||
| } | ||
|
|
||
|
|
||
| // Test 7: Exact Boundary Backreference (Distance == Output Size + 1) | ||
| // We need some initial data to be valid and a full block to reset flags. | ||
| // Block 1: 8 Literals [0x00, 'A'...'H'] -> Output "ABCDEFGH" (size 8) | ||
| // Block 2: Flags [0x01] (1st item Ref) | ||
| // Ref bytes [0x00, 0x90] -> Dist 9, Len 3. | ||
| // | ||
| // Distance 9 == Output Size 8 + 1. | ||
| // Implementation clamps distance to output.size() = 8. | ||
| // Start = 8 - 8 = 0. | ||
| // Copies output[0]...output[2] -> "ABC". | ||
| // Result: "ABCDEFGHABC". | ||
| { | ||
| std::cout << " Test 7: Exact Boundary Backreference... "; | ||
| std::vector<uint8_t> input = { | ||
| 0x00, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // Block 1 | ||
| 0x01, 0x00, 0x90 // Block 2 | ||
| }; | ||
| auto output = decompressor.decompress(input.data(), input.size()); | ||
|
|
||
| ASSERT_EQ(output.size(), 11); | ||
| std::string s(output.begin(), output.end()); | ||
| ASSERT_EQ(s, "ABCDEFGHABC"); | ||
| std::cout << "Passed.\n"; | ||
| } | ||
|
Comment on lines
+122
to
+145
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test case is identical to the one added in |
||
|
|
||
| std::cout << "[EDGE] All tests passed.\n"; | ||
| return 0; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
run_lz77_tests.shis missing a shebang, so running it directly (e.g.,./run_lz77_tests.sh) will typically fail with an exec format error. Add a#!/bin/bash(or#!/usr/bin/env bash) header and considerset -e(or equivalent) so failures inmakepropagate reliably.