Skip to content

Commit 1825636

Browse files
committed
test: check the Display impl of HttpContentRange and HttpRange
1 parent 3e7288c commit 1825636

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/headers/tests.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ mod content_range {
5858
);
5959
}
6060

61+
#[test]
62+
fn succesful_sized_bound_to_string() {
63+
assert_eq!(
64+
"bytes 10-20/50",
65+
&HttpContentRange::Bound(Bound::new(10..=20, Some(50)).unwrap()).to_string()
66+
);
67+
}
68+
6169
#[test]
6270
fn succesful_unsized_bound_parsing() {
6371
assert_eq!(
@@ -66,6 +74,14 @@ mod content_range {
6674
);
6775
}
6876

77+
#[test]
78+
fn succesful_unsized_bound_to_string() {
79+
assert_eq!(
80+
"bytes 10-20/*",
81+
&HttpContentRange::Bound(Bound::new(10..=20, None).unwrap()).to_string()
82+
);
83+
}
84+
6985
#[test]
7086
fn succesful_unsatisfiable_parsing() {
7187
assert_eq!(
@@ -74,6 +90,14 @@ mod content_range {
7490
);
7591
}
7692

93+
#[test]
94+
fn succesful_unsatisfiable_to_string() {
95+
assert_eq!(
96+
"bytes */50",
97+
&HttpContentRange::Unsatisfiable(Unsatisfiable::new(50)).to_string()
98+
);
99+
}
100+
77101
mod expected_range {
78102
use crate::headers::{
79103
OrderedRange,
@@ -143,6 +167,11 @@ mod range {
143167
);
144168
}
145169

170+
#[test]
171+
fn succesful_starting_to_string() {
172+
assert_eq!("bytes=50-", &HttpRange::StartingPoint(50).to_string());
173+
}
174+
146175
#[test]
147176
fn succesful_range_parsing() {
148177
assert_eq!(
@@ -151,11 +180,24 @@ mod range {
151180
);
152181
}
153182

183+
#[test]
184+
fn succesful_range_to_string() {
185+
assert_eq!(
186+
"bytes=50-100",
187+
&HttpRange::Range(OrderedRange::new(50..=100).unwrap()).to_string()
188+
);
189+
}
190+
154191
#[test]
155192
fn succesful_suffix_parsing() {
156193
assert_eq!(
157194
"bytes=-100".parse::<HttpRange>().unwrap(),
158195
HttpRange::Suffix(100)
159196
);
160197
}
198+
199+
#[test]
200+
fn succesful_suffix_to_string() {
201+
assert_eq!("bytes=-100", &HttpRange::Suffix(100).to_string());
202+
}
161203
}

0 commit comments

Comments
 (0)