This commit is contained in:
parent
facbde55bd
commit
7846f91afe
11 changed files with 209 additions and 54 deletions
|
|
@ -2,7 +2,14 @@ use rustbot::bot::module::{Action, Command, Module};
|
|||
use rustbot::bot::modules::{builtins::Builtins, dice::Dice};
|
||||
|
||||
fn cmd<'a>(name: &'a str, args: &'a [&'a str]) -> Command<'a> {
|
||||
Command { sender: "alice", reply_to: "#chan", name, args, prefix: ">", network: "test" }
|
||||
Command {
|
||||
sender: "alice",
|
||||
reply_to: "#chan",
|
||||
name,
|
||||
args,
|
||||
prefix: ">",
|
||||
network: "test",
|
||||
}
|
||||
}
|
||||
|
||||
fn reply(actions: &[Action]) -> &str {
|
||||
|
|
@ -21,7 +28,10 @@ fn builtins_ping_pongs() {
|
|||
#[test]
|
||||
fn builtins_echo_joins_args() {
|
||||
let mut m = Builtins;
|
||||
assert_eq!(reply(&m.on_command(&cmd("echo", &["hello", "world"]))), "hello world");
|
||||
assert_eq!(
|
||||
reply(&m.on_command(&cmd("echo", &["hello", "world"]))),
|
||||
"hello world"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -43,7 +53,10 @@ fn dice_2d6_total_is_in_range() {
|
|||
for _ in 0..300 {
|
||||
let r = reply(&d.on_command(&cmd("roll", &["2d6"]))).to_string();
|
||||
let total: u64 = r.rsplit('=').next().unwrap().trim().parse().unwrap();
|
||||
assert!((2..=12).contains(&total), "2d6 total {total} out of range: {r:?}");
|
||||
assert!(
|
||||
(2..=12).contains(&total),
|
||||
"2d6 total {total} out of range: {r:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue