Skip to content

Commit 334be72

Browse files
committed
test(decompression-plz): EndExtraRawMainDone - single compression
1 parent ca5434d commit 334be72

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

decompression-plz/src/state.rs

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -369,18 +369,38 @@ mod tests {
369369
state = state.try_next().unwrap();
370370
assert!(matches!(state, State::ExtraPlusMainTry(_)));
371371
state = state.try_next().unwrap();
372+
assert!(matches!(state, State::ExtraRawMainTry(_)));
373+
state = state.try_next().unwrap();
372374
dbg!(&state);
373-
if let State::EndMainPlusExtra(main) = state {
374-
dbg!(&main);
375-
assert_eq!(main, "hello world");
375+
if let State::EndExtraRawMainDone(dstruct, result) = state {
376+
assert_eq!(result, INPUT);
377+
assert_eq!(dstruct.extra.unwrap(), b"extra");
376378
}
377-
// assert!(matches!(state, State::ExtraRawMainTry(_)));
379+
}
380+
381+
fn build_single_compression(encoding: ContentEncoding) {
382+
let main = single_compression(&encoding);
383+
let mut info = vec![EncodingInfo::new(0, vec![encoding])];
384+
assert_main_compressed_extra_raw_flow(&mut info, &main, b"extra");
385+
}
386+
387+
#[test]
388+
fn test_state_main_compressed_exra_raw_single_compression_gzip() {
389+
build_single_compression(ContentEncoding::Gzip);
390+
}
391+
392+
#[test]
393+
fn test_state_main_compressed_exra_raw_single_compression_brotli() {
394+
build_single_compression(ContentEncoding::Brotli);
395+
}
396+
397+
#[test]
398+
fn test_state_main_compressed_exra_raw_single_compression_deflate() {
399+
build_single_compression(ContentEncoding::Deflate);
378400
}
379401

380402
#[test]
381-
fn test_state_main_compressed_exra_raw_single_compression() {
382-
let mut info = vec![EncodingInfo::new(0, vec![ContentEncoding::Gzip])];
383-
let main = compress_gzip(b"Hello ");
384-
assert_main_compressed_extra_raw_flow(&mut info, &main, b"world");
403+
fn test_state_main_compressed_exra_raw_single_compression_zstd() {
404+
build_single_compression(ContentEncoding::Zstd);
385405
}
386406
}

0 commit comments

Comments
 (0)