Add Rust tests and less code
This commit is contained in:
parent
61f57a2969
commit
2d104a2ae3
31
src/geom.rs
31
src/geom.rs
|
@ -1,29 +1,19 @@
|
|||
use std::os::raw::*;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Default)]
|
||||
pub struct Position {
|
||||
x: c_int,
|
||||
y: c_int,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Default)]
|
||||
pub struct Sizes {
|
||||
width: c_int,
|
||||
height: c_int,
|
||||
}
|
||||
|
||||
impl Default for Position {
|
||||
fn default() -> Self {
|
||||
Self::new(0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Sizes {
|
||||
fn default() -> Self {
|
||||
Self::new(0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
impl Position {
|
||||
pub fn new(x: c_int, y: c_int) -> Self {
|
||||
Self { x, y }
|
||||
|
@ -51,3 +41,20 @@ impl Sizes {
|
|||
self.height
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn position_default() {
|
||||
assert_eq!(Position::default().x(), 0);
|
||||
assert_eq!(Position::default().y(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sizes_default() {
|
||||
assert_eq!(Sizes::default().width(), 0);
|
||||
assert_eq!(Sizes::default().height(), 0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue