mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
move test crate into core
This commit is contained in:
parent
02db343574
commit
0a842b607a
12 changed files with 523 additions and 507 deletions
75
crates/tek_core/src/test.rs
Normal file
75
crates/tek_core/src/test.rs
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
use crate::*;
|
||||
|
||||
#[test]
|
||||
fn test_offset () -> Usually<()> {
|
||||
let area: [u16;4] = [50, 50, 100, 100];
|
||||
assert_eq!(Offset::X(1, "1").layout(area)?, Some([51, 50, 1, 1]));
|
||||
assert_eq!(Offset::Y(1, "1").layout(area)?, Some([50, 51, 1, 1]));
|
||||
assert_eq!(Offset::XY(1, 1, "1").layout(area)?, Some([51, 51, 1, 1]));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_outset () -> Usually<()> {
|
||||
let area: [u16;4] = [50, 50, 100, 100];
|
||||
assert_eq!(Outset::X(1, "1").layout(area)?, Some([49, 50, 3, 1]));
|
||||
assert_eq!(Outset::Y(1, "1").layout(area)?, Some([50, 49, 1, 3]));
|
||||
assert_eq!(Outset::XY(1, 1, "1").layout(area)?, Some([49, 49, 3, 3]));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_stuff () -> Usually<()> {
|
||||
let area: [u16;4] = [0, 0, 100, 100];
|
||||
assert_eq!("1".layout(area)?,
|
||||
Some([0, 0, 1, 1]));
|
||||
assert_eq!("333".layout(area)?,
|
||||
Some([0, 0, 3, 1]));
|
||||
assert_eq!(Layers::new(|add|{add(&"1")?;add(&"333")}).layout(area)?,
|
||||
Some([0, 0, 3, 1]));
|
||||
assert_eq!(Split::down(|add|{add(&"1")?;add(&"333")}).layout(area)?,
|
||||
Some([0, 0, 3, 2]));
|
||||
assert_eq!(Split::right(|add|{add(&"1")?;add(&"333")}).layout(area)?,
|
||||
Some([0, 0, 4, 1]));
|
||||
assert_eq!(Split::down(|add|{
|
||||
add(&Split::right(|add|{add(&"1")?;add(&"333")}))?;
|
||||
add(&"55555")
|
||||
}).layout(area)?,
|
||||
Some([0, 0, 5, 2]));
|
||||
let area: [u16;4] = [1, 1, 100, 100];
|
||||
assert_eq!(Outset::X(1, Split::right(|add|{add(&"1")?;add(&"333")})).layout(area)?,
|
||||
Some([0, 1, 6, 1]));
|
||||
assert_eq!(Outset::Y(1, Split::right(|add|{add(&"1")?;add(&"333")})).layout(area)?,
|
||||
Some([1, 0, 4, 3]));
|
||||
assert_eq!(Outset::XY(1, 1, Split::right(|add|{add(&"1")?;add(&"333")})).layout(area)?,
|
||||
Some([0, 0, 6, 3]));
|
||||
assert_eq!(Split::down(|add|{
|
||||
add(&Outset::XY(1, 1, "1"))?;
|
||||
add(&Outset::XY(1, 1, "333"))
|
||||
}).layout(area)?,
|
||||
Some([1, 1, 5, 6]));
|
||||
let area: [u16;4] = [1, 1, 95, 100];
|
||||
assert_eq!(Align::Center(Split::down(|add|{
|
||||
add(&Outset::XY(1, 1, "1"))?;
|
||||
add(&Outset::XY(1, 1, "333"))
|
||||
})).layout(area)?,
|
||||
Some([46, 48, 5, 6]));
|
||||
assert_eq!(Align::Center(Split::down(|add|{
|
||||
add(&Layers::new(|add|{
|
||||
//add(&Outset::XY(1, 1, FillBg(Color::Rgb(0,128,0))))?;
|
||||
add(&Outset::XY(1, 1, "1"))?;
|
||||
add(&Outset::XY(1, 1, "333"))?;
|
||||
//add(&FillBg(Color::Rgb(0,128,0)))?;
|
||||
Ok(())
|
||||
}))?;
|
||||
add(&Layers::new(|add|{
|
||||
//add(&Outset::XY(1, 1, FillBg(Color::Rgb(0,0,128))))?;
|
||||
add(&Outset::XY(1, 1, "555"))?;
|
||||
add(&Outset::XY(1, 1, "777777"))?;
|
||||
//add(&FillBg(Color::Rgb(0,0,128)))?;
|
||||
Ok(())
|
||||
}))
|
||||
})).layout(area)?,
|
||||
Some([46, 48, 5, 6]));
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue