Skip to content

Commit

Permalink
Add test coverage for the StatusCode is_xxxxx() functions (#545)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivd-git authored Apr 15, 2022
1 parent c28945c commit ec616ed
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions tests/status_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,52 @@ fn roundtrip() {
assert_eq!(sstr, status.as_str());
}
}

#[test]
fn is_informational() {
assert!(status_code(100).is_informational());
assert!(status_code(199).is_informational());

assert!(!status_code(200).is_informational());
}

#[test]
fn is_success() {
assert!(status_code(200).is_success());
assert!(status_code(299).is_success());

assert!(!status_code(199).is_success());
assert!(!status_code(300).is_success());
}

#[test]
fn is_redirection() {
assert!(status_code(300).is_redirection());
assert!(status_code(399).is_redirection());

assert!(!status_code(299).is_redirection());
assert!(!status_code(400).is_redirection());
}

#[test]
fn is_client_error() {
assert!(status_code(400).is_client_error());
assert!(status_code(499).is_client_error());

assert!(!status_code(399).is_client_error());
assert!(!status_code(500).is_client_error());
}

#[test]
fn is_server_error() {
assert!(status_code(500).is_server_error());
assert!(status_code(599).is_server_error());

assert!(!status_code(499).is_server_error());
assert!(!status_code(600).is_server_error());
}

/// Helper method for readability
fn status_code(status_code: u16) -> StatusCode {
StatusCode::from_u16(status_code).unwrap()
}

0 comments on commit ec616ed

Please sign in to comment.