From 18ebb9851596cfea7776da7a850e0afe9c46c041 Mon Sep 17 00:00:00 2001 From: tottoto Date: Tue, 26 Mar 2024 20:32:23 +0900 Subject: [PATCH] refactor: refactor AcceptRanges test --- src/common/accept_ranges.rs | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/common/accept_ranges.rs b/src/common/accept_ranges.rs index d2da4e0f..3fcfc412 100644 --- a/src/common/accept_ranges.rs +++ b/src/common/accept_ranges.rs @@ -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()); } }