Skip to content

Commit

Permalink
test: Add tests for const fn
Browse files Browse the repository at this point in the history
  • Loading branch information
sorairolake committed Nov 8, 2024
1 parent 1bc67e8 commit ffd27ba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ mod tests {
assert_eq!(TryFromExitStatusError::new(None).code(), None);
}

#[cfg(feature = "std")]
#[test]
const fn code_try_from_exit_status_error_is_const_fn() {
const _: Option<i32> = TryFromExitStatusError::new(None).code();
}

#[cfg(feature = "std")]
#[test]
fn display_try_from_exit_status_error() {
Expand Down
10 changes: 10 additions & 0 deletions src/exit_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,11 @@ mod tests {
assert!(!ExitCode::Config.is_success());
}

#[test]
const fn is_success_is_const_fn() {
const _: bool = ExitCode::Ok.is_success();
}

#[test]
fn is_failure_for_successful_termination() {
assert!(!ExitCode::Ok.is_failure());
Expand All @@ -633,6 +638,11 @@ mod tests {
assert!(ExitCode::Config.is_failure());
}

#[test]
const fn is_failure_is_const_fn() {
const _: bool = ExitCode::Ok.is_failure();
}

#[cfg(feature = "std")]
#[test]
fn source() {
Expand Down

0 comments on commit ffd27ba

Please # to comment.