Skip to content

Commit a961482

Browse files
committed
test(decompression-plz): added tests for multi compression single header extra body
1 parent c56842a commit a961482

File tree

29 files changed

+250
-103
lines changed

29 files changed

+250
-103
lines changed

decompression-plz/tests/test_cases/both_te_ce.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ fn test_both_te_ce() {
66
let body: Vec<u8> = all_compressed_data();
77
let headers = format!(
88
"Host: example.com\r\n\
9-
Content-Type: text/html; charset=utf-8\r\n\
10-
Transfer-Encoding: gzip, zstd\r\n\
11-
Content-Encoding: br, deflate\r\n\
12-
Content-Length: {}\r\n\r\n",
9+
Content-Type: text/html; charset=utf-8\r\n\
10+
Transfer-Encoding: gzip, zstd\r\n\
11+
Content-Encoding: br, deflate\r\n\
12+
Content-Length: {}\r\n\r\n",
1313
body.len()
1414
);
1515

@@ -31,9 +31,5 @@ fn test_both_te_ce() {
3131
assert!(state.is_ended());
3232

3333
let result = tm.into_bytes();
34-
let verify = "Host: example.com\r\n\
35-
Content-Type: text/html; charset=utf-8\r\n\
36-
Content-Length: 11\r\n\r\n\
37-
hello world";
38-
assert_eq!(result, verify);
34+
assert_eq!(result, VERIFY_SINGLE_HEADER_BODY_ONLY);
3935
}

decompression-plz/tests/test_cases/extra/mod.rs

Lines changed: 0 additions & 1 deletion
This file was deleted.

decompression-plz/tests/test_cases/mod.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use header_plz::const_headers::{CONTENT_ENCODING, TRANSFER_ENCODING};
33
use super::*;
44
pub mod both_te_ce;
55
pub mod chunked;
6-
pub mod extra;
76
pub mod multi_compression;
87
pub mod no_encodings;
98
pub mod partial;
@@ -24,3 +23,13 @@ fn encoding_state(
2423
panic!("Unknown header");
2524
}
2625
}
26+
27+
const VERIFY_SINGLE_HEADER_BODY_ONLY: &str = "Host: example.com\r\n\
28+
Content-Type: text/html; charset=utf-8\r\n\
29+
Content-Length: 11\r\n\r\n\
30+
hello world";
31+
32+
const VERIFY_SINGLE_HEADER_BODY_AND_EXTRA: &str = "Host: example.com\r\n\
33+
Content-Type: text/html; charset=utf-8\r\n\
34+
Content-Length: 22\r\n\r\n\
35+
hello worldhello world";
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use super::*;
2+
3+
#[test]
4+
fn assert_decode_state_ce_all_multi_header() {
5+
let tm = build_test_message_all_encodings_multi_header(CONTENT_ENCODING);
6+
assert_case_multi_compression(tm, CONTENT_ENCODING, VERIFY_MULTI_HEADER);
7+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
use super::*;
2+
3+
mod ce;
4+
mod te;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use super::*;
2+
3+
#[test]
4+
fn assert_decode_state_te_all_multi_header() {
5+
let tm = build_test_message_all_encodings_multi_header(TRANSFER_ENCODING);
6+
assert_case_multi_compression(tm, TRANSFER_ENCODING, VERIFY_MULTI_HEADER);
7+
}

decompression-plz/tests/test_cases/multi_compression/multi_header.rs renamed to decompression-plz/tests/test_cases/multi_compression/multi_header/mod.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
use header_plz::const_headers::{CONTENT_ENCODING, TRANSFER_ENCODING};
22

33
use super::*;
4+
mod body_only;
5+
mod with_extra;
46

5-
const VERIFY: &str = "Host: example.com\r\n\
6-
Content-Type: text/html; charset=utf-8\r\n\
7-
random: random\r\n\
8-
another-random: random\r\n\
9-
test-header: test-header\r\n\
10-
Content-Length: 11\r\n\r\n\
11-
hello world";
7+
const VERIFY_MULTI_HEADER: &str = "Host: example.com\r\n\
8+
Content-Type: text/html; charset=utf-8\r\n\
9+
random: random\r\n\
10+
another-random: random\r\n\
11+
test-header: test-header\r\n\
12+
Content-Length: 11\r\n\r\n\
13+
hello world";
1214

1315
fn build_test_message_all_encodings_multi_header(
1416
header_name: &str,
@@ -44,12 +46,11 @@ fn build_test_message_all_encodings_multi_header(
4446
#[test]
4547
fn assert_decode_state_ce_all_multi_header() {
4648
let tm = build_test_message_all_encodings_multi_header(CONTENT_ENCODING);
47-
48-
assert_case_multi_compression(tm, CONTENT_ENCODING, VERIFY);
49+
assert_case_multi_compression(tm, CONTENT_ENCODING, VERIFY_MULTI_HEADER);
4950
}
5051

5152
#[test]
5253
fn assert_decode_state_te_all_multi_header() {
5354
let tm = build_test_message_all_encodings_multi_header(TRANSFER_ENCODING);
54-
assert_case_multi_compression(tm, TRANSFER_ENCODING, VERIFY);
55+
assert_case_multi_compression(tm, TRANSFER_ENCODING, VERIFY_MULTI_HEADER);
5556
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// mod ce;
2+
mod te;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//use super::*;
2+
//mod compressed_separate;
3+
//mod compressed_together;
4+
//mod raw;

decompression-plz/tests/test_cases/multi_compression/single_header.rs

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)