mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-02-21 18:49:04 +01:00
wip: test: fixing up the tests
- should bring back the rest of the mental model - and allow me to prune it!
This commit is contained in:
parent
ce2eeaee7f
commit
2a7e981b9c
5 changed files with 93 additions and 95 deletions
|
|
@ -1,3 +1,4 @@
|
|||
#[cfg(test)] use proptest_derive::Arbitrary;
|
||||
use crate::*;
|
||||
|
||||
/// A point (X, Y).
|
||||
|
|
@ -6,7 +7,9 @@ use crate::*;
|
|||
/// let xy: XY<u16> = XY(0, 0);
|
||||
/// ```
|
||||
#[cfg_attr(test, derive(Arbitrary))]
|
||||
#[derive(Copy, Clone, Debug, Default)] pub struct XY<C: Coord>(pub C, pub C);
|
||||
#[derive(Copy, Clone, Debug, Default, PartialEq)] pub struct XY<C: Coord>(
|
||||
pub C, pub C
|
||||
);
|
||||
|
||||
/// A size (Width, Height).
|
||||
///
|
||||
|
|
@ -14,7 +17,9 @@ use crate::*;
|
|||
/// let wh: WH<u16> = WH(0, 0);
|
||||
/// ```
|
||||
#[cfg_attr(test, derive(Arbitrary))]
|
||||
#[derive(Copy, Clone, Debug, Default)] pub struct WH<C: Coord>(pub C, pub C);
|
||||
#[derive(Copy, Clone, Debug, Default, PartialEq)] pub struct WH<C: Coord>(
|
||||
pub C, pub C
|
||||
);
|
||||
|
||||
/// Point with size.
|
||||
///
|
||||
|
|
@ -25,7 +30,9 @@ use crate::*;
|
|||
/// * [ ] TODO: anchor field (determines at which corner/side is X0 Y0)
|
||||
///
|
||||
#[cfg_attr(test, derive(Arbitrary))]
|
||||
#[derive(Copy, Clone, Debug, Default)] pub struct XYWH<C: Coord>(pub C, pub C, pub C, pub C);
|
||||
#[derive(Copy, Clone, Debug, Default, PartialEq)] pub struct XYWH<C: Coord>(
|
||||
pub C, pub C, pub C, pub C
|
||||
);
|
||||
|
||||
/// A cardinal direction.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use proptest_derive::Arbitrary;
|
|||
use crate::*;
|
||||
|
||||
#[test] fn test_area () {
|
||||
assert_eq!(Area::center(&[10u16, 10, 20, 20]), [20, 20]);
|
||||
assert_eq!(XYWH(10u16, 10, 20, 20).center(), XY(20, 20));
|
||||
}
|
||||
|
||||
proptest! {
|
||||
|
|
@ -19,7 +19,7 @@ proptest! {
|
|||
h in u16::MIN..u16::MAX,
|
||||
a in u16::MIN..u16::MAX,
|
||||
) {
|
||||
let _ = d.split_fixed([x, y, w, h], a);
|
||||
let _ = d.split_fixed(XYWH(x, y, w, h), a);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -32,27 +32,27 @@ proptest! {
|
|||
a in u16::MIN..u16::MAX,
|
||||
b in u16::MIN..u16::MAX,
|
||||
) {
|
||||
let _: [u16;4] = <[u16;4] as Area<u16>>::zero();
|
||||
let _: [u16;4] = <[u16;4] as Area<u16>>::from_position([a, b]);
|
||||
let _: [u16;4] = <[u16;4] as Area<u16>>::from_size([a, b]);
|
||||
let area: [u16;4] = [x, y, w, h];
|
||||
let _ = area.expect_min(a, b);
|
||||
let _: XYWH<u16> = XYWH::zero();
|
||||
//let _: XYWH<u16> = XYWH::from_position([a, b]);
|
||||
//let _: XYWH<u16> = XYWH::from_size([a, b]);
|
||||
let area: XYWH<u16> = XYWH(x, y, w, h);
|
||||
//let _ = area.expect_min(a, b);
|
||||
let _ = area.xy();
|
||||
let _ = area.wh();
|
||||
let _ = area.xywh();
|
||||
let _ = area.clip_h(a);
|
||||
let _ = area.clip_w(b);
|
||||
let _ = area.clip([a, b]);
|
||||
let _ = area.set_w(a);
|
||||
let _ = area.set_h(b);
|
||||
//let _ = area.xywh();
|
||||
let _ = area.clipped_h(a);
|
||||
let _ = area.clipped_w(b);
|
||||
let _ = area.clipped(WH(a, b));
|
||||
//let _ = area.set_w(a);
|
||||
//let _ = area.set_h(b);
|
||||
let _ = area.x2();
|
||||
let _ = area.y2();
|
||||
let _ = area.lrtb();
|
||||
let _ = area.center();
|
||||
let _ = area.center_x(a);
|
||||
let _ = area.center_y(b);
|
||||
let _ = area.center_xy([a, b]);
|
||||
let _ = area.centered();
|
||||
let _ = area.centered_x(a);
|
||||
let _ = area.centered_y(b);
|
||||
let _ = area.centered_xy([a, b]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -63,15 +63,15 @@ proptest! {
|
|||
a in u16::MIN..u16::MAX,
|
||||
b in u16::MIN..u16::MAX,
|
||||
) {
|
||||
let size = [x, y];
|
||||
let size = WH(x, y);
|
||||
let _ = size.w();
|
||||
let _ = size.h();
|
||||
let _ = size.wh();
|
||||
let _ = size.clip_w(a);
|
||||
let _ = size.clip_h(b);
|
||||
let _ = size.expect_min(a, b);
|
||||
let _ = size.to_area_pos();
|
||||
let _ = size.to_area_size();
|
||||
//let _ = size.expect_min(a, b);
|
||||
//let _ = size.to_area_pos();
|
||||
//let _ = size.to_area_size();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue