Skip to content

Commit

Permalink
tests: refactor AcceptRanges test (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto authored Mar 26, 2024
1 parent 86fe9ce commit 0a258a0
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/common/accept_ranges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,30 @@ impl AcceptRanges {

#[cfg(test)]
mod tests {
use super::super::test_decode;
use super::*;

fn accept_ranges(s: &str) -> AcceptRanges {
test_decode(&[s]).unwrap()
}

#[test]
fn bytes_constructor() {
assert_eq!(accept_ranges("bytes"), AcceptRanges::bytes());
}

#[test]
fn is_bytes_method_successful_with_bytes_ranges() {
assert!(accept_ranges("bytes").is_bytes());
}

#[test]
fn bytes() {
let bytes_range = AcceptRanges::bytes();
assert!(bytes_range.is_bytes());
fn is_bytes_method_successful_with_bytes_ranges_by_constructor() {
assert!(AcceptRanges::bytes().is_bytes());
}

#[test]
fn bytes_fails() {
let none_range = AcceptRanges(HeaderValue::from_static("none").into());
assert!(!none_range.is_bytes());
fn is_bytes_method_failed_with_not_bytes_ranges() {
assert!(!accept_ranges("dummy").is_bytes());
}
}

0 comments on commit 0a258a0

Please sign in to comment.