Improve testing
This commit is contained in:
parent
a4f0c0bcc8
commit
ce84cc52d8
1 changed files with 23 additions and 16 deletions
|
@ -31,25 +31,32 @@ callbacks!(SelectCallbacks, Fn(bool) -> anyhow::Result<()> + Send + Sync);
|
||||||
callbacks!(CustomCallbacks, Fn(ControllerButton) -> anyhow::Result<bool> + Send + Sync);
|
callbacks!(CustomCallbacks, Fn(ControllerButton) -> anyhow::Result<bool> + Send + Sync);
|
||||||
callbacks!(VecCallbacks, Fn(&dyn Any) -> Result<()> + Send + Sync);
|
callbacks!(VecCallbacks, Fn(&dyn Any) -> Result<()> + Send + Sync);
|
||||||
|
|
||||||
#[test]
|
#[cfg(test)]
|
||||||
fn test_click_callback_builder() {
|
mod test {
|
||||||
struct Test;
|
use super::*;
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
impl Test {
|
fn normal_fn() -> impl Fn() -> Result<()> + Send + Sync {
|
||||||
fn set_click_callbacks(
|
|| Ok(())
|
||||||
&self,
|
|
||||||
_callbacks: Vec<(&str, Box<dyn Fn() -> Result<()> + Send + Sync>)>,
|
|
||||||
) -> Result<()> {
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let t = Test;
|
#[test]
|
||||||
|
fn test_click_callback_builder() {
|
||||||
|
struct Test;
|
||||||
|
|
||||||
let cbs = ClickCallbacks::default().add("test", || {
|
impl Test {
|
||||||
println!("hello world!");
|
fn set_click_callbacks(
|
||||||
Ok(())
|
&self,
|
||||||
});
|
_callbacks: Vec<(&str, Box<dyn Fn() -> Result<()> + Send + Sync>)>,
|
||||||
|
) -> Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
t.set_click_callbacks(cbs.into()).unwrap();
|
let t = Test;
|
||||||
|
|
||||||
|
let cbs = ClickCallbacks::default().add("normal_test", normal_fn());
|
||||||
|
|
||||||
|
t.set_click_callbacks(cbs.into()).unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue