mirror of
https://github.com/valmojr/armatak.git
synced 2026-06-13 22:23:30 +00:00
idk
This commit is contained in:
40
vendor/arma-rs/examples/hello_world.rs
vendored
Normal file
40
vendor/arma-rs/examples/hello_world.rs
vendored
Normal file
@@ -0,0 +1,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, _) = extension.call("hello", None);
|
||||
assert_eq!(result, "Hello");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn welcome() {
|
||||
let extension = init().testing();
|
||||
let (result, _) = 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() {}
|
||||
Reference in New Issue
Block a user