Skip to content

Commit 91ca4c3

Browse files
committed
fix some unit tests
1 parent daf4c8d commit 91ca4c3

4 files changed

Lines changed: 19 additions & 13 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.0.1] - 2024/12/07
9+
10+
### Fixes
11+
12+
* Repair broken unit tests (issue #2)
13+
814
## [1.0.0] - 2024/09/08
915

1016
### New Features
1117

1218
* Support for LZW compression
13-
* Support for Teledisk 1.x
19+
* Support for Teledisk 1.x (issue #1)
1420
* Emit a warning about truncation policy
1521
* Compression options are public
1622
* Error is returned for unreasonably large files, controlled by options

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "retrocompressor"
3-
version = "1.0.0"
3+
version = "1.0.1"
44
edition = "2021"
55
readme = "README.md"
66
license = "MIT"

src/lzw.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,8 @@ where R: Read + Seek, W: Write + Seek {
469469
}
470470
old_coder_state = coder.clone();
471471
write_offset_header = save_offset;
472-
// back up to catch the character left in the dictionary that will be cleared
473-
read_chunk_offset = reader.stream_position()?;// - 1;
472+
// read-position should be on the last symbol that didn't match
473+
read_chunk_offset = reader.stream_position()?;
474474
break;
475475
}
476476
}
@@ -656,8 +656,8 @@ fn invertibility() {
656656
let mut opt = STD_OPTIONS;
657657
opt.ord = BitOrder::Msb0;
658658
let test_data = "I am Sam. Sam I am. I do not like this Sam I am.\n".as_bytes();
659-
let compressed = compress_slice(test_data,&STD_OPTIONS).expect("compression failed");
660-
let expanded = expand_slice(&compressed,&STD_OPTIONS).expect("expansion failed");
659+
let compressed = compress_slice(test_data,&opt).expect("compression failed");
660+
let expanded = expand_slice(&compressed,&opt).expect("expansion failed");
661661
assert_eq!(test_data.to_vec(),expanded);
662662
}
663663

@@ -668,8 +668,8 @@ fn invertibility_16() {
668668
opt.min_code_width = 16;
669669
opt.max_code_width = 16;
670670
let test_data = "I am Sam. Sam I am. I do not like this Sam I am.\n".as_bytes();
671-
let compressed = compress_slice(test_data,&STD_OPTIONS).expect("compression failed");
672-
let expanded = expand_slice(&compressed,&STD_OPTIONS).expect("expansion failed");
671+
let compressed = compress_slice(test_data,&opt).expect("compression failed");
672+
let expanded = expand_slice(&compressed,&opt).expect("expansion failed");
673673
assert_eq!(test_data.to_vec(),expanded);
674674
}
675675

@@ -679,8 +679,8 @@ fn invertibility_td_mode() {
679679
opt.in_offset = 0;
680680
opt.out_offset = 0;
681681
let test_data = "I am Sam. Sam I am. I do not like this Sam I am.\n".as_bytes();
682-
let compressed = compress_slice(test_data,&STD_OPTIONS).expect("compression failed");
683-
let expanded = expand_slice(&compressed,&STD_OPTIONS).expect("expansion failed");
682+
let compressed = compress_slice(test_data,&opt).expect("compression failed");
683+
let expanded = expand_slice(&compressed,&opt).expect("expansion failed");
684684
assert_eq!(test_data.to_vec(),expanded);
685685
}
686686

@@ -690,7 +690,7 @@ fn invertibility_with_clear() {
690690
opt.ord = BitOrder::Msb0;
691691
opt.chunk_size = 14;
692692
let test_data = "I am Sam. Sam I am. I do not like this Sam I am.\n".as_bytes();
693-
let compressed = compress_slice(test_data,&STD_OPTIONS).expect("compression failed");
694-
let expanded = expand_slice(&compressed,&STD_OPTIONS).expect("expansion failed");
693+
let compressed = compress_slice(test_data,&opt).expect("compression failed");
694+
let expanded = expand_slice(&compressed,&opt).expect("expansion failed");
695695
assert_eq!(test_data.to_vec(),expanded);
696696
}

0 commit comments

Comments
 (0)