Skip to content

Commit

Permalink
test: unit test the bits! macro
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulrahman1s committed Jul 20, 2022
1 parent 87805f7 commit 8ad8de7
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/utils/permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,29 @@ impl OpgModel for Permissions {
None
}
}

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

#[test]
fn all() {
assert!(bits![ALL].is_all());
}

#[test]
fn default() {
assert_eq!(bits![], Permissions::default());
}

#[test]
fn one_parameter() {
assert!(Permissions::VIEW_CHANNEL.contains(bits![VIEW_CHANNEL]));
}

#[test]
fn multiple_parameters() {
let p = Permissions::VIEW_CHANNEL | Permissions::SEND_MESSAGES;
assert!(p.contains(bits![VIEW_CHANNEL, SEND_MESSAGES]));
}
}

0 comments on commit 8ad8de7

Please sign in to comment.