Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/headers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl OrderedRange {

impl Display for OrderedRange {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{UNIT}={}-{}", self.start(), self.end())
write!(f, "{}-{}", self.start(), self.end())
}
}

Expand Down
42 changes: 42 additions & 0 deletions src/headers/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ mod content_range {
);
}

#[test]
fn succesful_sized_bound_to_string() {
assert_eq!(
"bytes 10-20/50",
&HttpContentRange::Bound(Bound::new(10..=20, Some(50)).unwrap()).to_string()
);
}

#[test]
fn succesful_unsized_bound_parsing() {
assert_eq!(
Expand All @@ -66,6 +74,14 @@ mod content_range {
);
}

#[test]
fn succesful_unsized_bound_to_string() {
assert_eq!(
"bytes 10-20/*",
&HttpContentRange::Bound(Bound::new(10..=20, None).unwrap()).to_string()
);
}

#[test]
fn succesful_unsatisfiable_parsing() {
assert_eq!(
Expand All @@ -74,6 +90,14 @@ mod content_range {
);
}

#[test]
fn succesful_unsatisfiable_to_string() {
assert_eq!(
"bytes */50",
&HttpContentRange::Unsatisfiable(Unsatisfiable::new(50)).to_string()
);
}

mod expected_range {
use crate::headers::{
OrderedRange,
Expand Down Expand Up @@ -143,6 +167,11 @@ mod range {
);
}

#[test]
fn succesful_starting_to_string() {
assert_eq!("bytes=50-", &HttpRange::StartingPoint(50).to_string());
}

#[test]
fn succesful_range_parsing() {
assert_eq!(
Expand All @@ -151,11 +180,24 @@ mod range {
);
}

#[test]
fn succesful_range_to_string() {
assert_eq!(
"bytes=50-100",
&HttpRange::Range(OrderedRange::new(50..=100).unwrap()).to_string()
);
}

#[test]
fn succesful_suffix_parsing() {
assert_eq!(
"bytes=-100".parse::<HttpRange>().unwrap(),
HttpRange::Suffix(100)
);
}

#[test]
fn succesful_suffix_to_string() {
assert_eq!("bytes=-100", &HttpRange::Suffix(100).to_string());
}
}