1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use arma_rs::{arma, Extension};

#[arma]
fn init() -> Extension {
    Extension::build()
        .version("1.0.0".to_string())
        .command("hello", hello)
        .command("welcome", welcome)
        .finish()
}

pub fn hello() -> &'static str {
    "Hello"
}

pub fn welcome(name: String) -> String {
    format!("Welcome {}", name)
}

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

    #[test]
    fn hello() {
        let extension = init().testing();
        let (result, _) = unsafe { extension.call("hello", None) };
        assert_eq!(result, "Hello");
    }

    #[test]
    fn welcome() {
        let extension = init().testing();
        let (result, _) = unsafe { extension.call("welcome", Some(vec!["John".to_string()])) };
        assert_eq!(result, "Welcome John");
    }
}

// Only required for cargo, don't include in your library
fn main() {}