Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andybarron committed Feb 25, 2022
1 parent 145fd94 commit f09cce7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tokio/src/signal/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ impl From<std::os::raw::c_int> for SignalKind {

impl From<SignalKind> for std::os::raw::c_int {
fn from(kind: SignalKind) -> Self {
kind.0
kind.value()
}
}

Expand Down Expand Up @@ -497,4 +497,15 @@ mod tests {
)
.unwrap_err();
}

#[test]
fn from_c_int() {
assert_eq!(SignalKind::from(2), SignalKind::interrupt());
}

#[test]
fn into_c_int() {
let value: std::os::raw::c_int = SignalKind::interrupt().into();
assert_eq!(value, libc::SIGINT as _);
}
}

0 comments on commit f09cce7

Please sign in to comment.