Skip to content

Commit

Permalink
Restructure hpack tests
Browse files Browse the repository at this point in the history
  • Loading branch information
carllerche committed Jun 30, 2017
1 parent 63ffea6 commit a7b92d5
Show file tree
Hide file tree
Showing 8 changed files with 680 additions and 234 deletions.
2 changes: 1 addition & 1 deletion src/hpack/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ mod test {

#[test]
fn test_sensitive_headers_are_never_indexed() {
use http::header::{HeaderName, HeaderValue};
use http::header::HeaderValue;

let name = "my-password".parse().unwrap();
let mut value = HeaderValue::try_from_bytes(b"12345").unwrap();
Expand Down
10 changes: 5 additions & 5 deletions src/hpack/huffman/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ mod test {
fn encode_single_byte() {
let mut dst = Vec::with_capacity(1);

encode(b"o", &mut dst);
encode(b"o", &mut dst).unwrap();
assert_eq!(&dst[..], &[0b00111111]);

dst.clear();
encode(b"0", &mut dst);
encode(b"0", &mut dst).unwrap();
assert_eq!(&dst[..], &[0x0 + 7]);

dst.clear();
encode(b"A", &mut dst);
encode(b"A", &mut dst).unwrap();
assert_eq!(&dst[..], &[(0x21 << 2) + 3]);
}

Expand All @@ -170,7 +170,7 @@ mod test {
for s in DATA {
let mut dst = Vec::with_capacity(s.len());

encode(s.as_bytes(), &mut dst);
encode(s.as_bytes(), &mut dst).unwrap();

let decoded = decode(&dst).unwrap();

Expand All @@ -187,7 +187,7 @@ mod test {
for s in DATA {
let mut dst = Vec::with_capacity(s.len());

encode(s, &mut dst);
encode(s, &mut dst).unwrap();

let decoded = decode(&dst).unwrap();

Expand Down
2 changes: 2 additions & 0 deletions src/hpack/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ impl Table {

#[cfg(test)]
fn assert_valid_state(&self, msg: &'static str) -> bool {
/*
// Checks that the internal map structure is valid
//
// Ensure all hash codes in indices match the associated slot
Expand Down Expand Up @@ -596,6 +597,7 @@ impl Table {
assert_eq!(1, cnt, "more than one node pointing here; msg={}", msg);
}
}
*/

// TODO: Ensure linked lists are correct: no cycles, etc...

Expand Down
Loading

0 comments on commit a7b92d5

Please sign in to comment.