mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
what is up with those tests!
This commit is contained in:
parent
01835c8077
commit
7ddb95d521
6 changed files with 87 additions and 88 deletions
|
|
@ -1,44 +1,25 @@
|
|||
#![feature(associated_type_defaults)]
|
||||
|
||||
//mod component; pub use self::component::*;
|
||||
mod engine; pub use self::engine::*;
|
||||
mod input; pub use self::input::*;
|
||||
mod handle; pub use self::handle::*;
|
||||
mod command; pub use self::command::*;
|
||||
mod event_map; pub use self::event_map::*;
|
||||
|
||||
pub(crate) use std::marker::PhantomData;
|
||||
/// Standard error trait.
|
||||
pub(crate) use std::error::Error;
|
||||
|
||||
/// Standard result type.
|
||||
pub(crate) type Usually<T> = Result<T, Box<dyn Error>>;
|
||||
|
||||
/// Standard optional result type.
|
||||
pub(crate) type Perhaps<T> = Result<Option<T>, Box<dyn Error>>;
|
||||
|
||||
#[cfg(test)] #[test] fn test_dimensions () {
|
||||
assert_eq!(Area::center(&[10u16, 10, 20, 20]), [20, 20]);
|
||||
}
|
||||
|
||||
#[cfg(test)] #[test] fn test_stub_engine () -> Usually<()> {
|
||||
#[cfg(test)] #[test] fn test_stub_input () -> Usually<()> {
|
||||
use crate::*;
|
||||
struct TestEngine(bool);
|
||||
struct TestInput(bool);
|
||||
struct TestOutput([u16;4]);
|
||||
enum TestEvent { Test1 }
|
||||
impl Engine for TestEngine {
|
||||
type Input = TestInput;
|
||||
type Handled = ();
|
||||
type Output = TestOutput;
|
||||
type Unit = u16;
|
||||
type Size = [u16;2];
|
||||
type Area = [u16;4];
|
||||
fn exited (&self) -> bool {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
impl Input<TestEngine> for TestInput {
|
||||
impl Input for TestInput {
|
||||
type Event = TestEvent;
|
||||
type Handled = ();
|
||||
fn event (&self) -> &Self::Event {
|
||||
&TestEvent::Test1
|
||||
}
|
||||
|
|
@ -47,21 +28,5 @@ pub(crate) type Perhaps<T> = Result<Option<T>, Box<dyn Error>>;
|
|||
}
|
||||
fn done (&self) {}
|
||||
}
|
||||
impl Output<TestEngine> for TestOutput {
|
||||
fn area (&self) -> [u16;4] {
|
||||
self.0
|
||||
}
|
||||
fn area_mut (&mut self) -> &mut [u16;4] {
|
||||
&mut self.0
|
||||
}
|
||||
fn place (&mut self, _: [u16;4], _: &impl Render<TestEngine>) {
|
||||
()
|
||||
}
|
||||
}
|
||||
impl Content<TestEngine> for String {
|
||||
fn render (&self, to: &mut TestOutput) {
|
||||
to.area_mut().set_w(self.len() as u16);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue