Add Rust tests and less code

This commit is contained in:
Alex Kotov 2022-09-07 19:41:32 +04:00
parent 61f57a2969
commit 2d104a2ae3
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
1 changed files with 19 additions and 12 deletions

View File

@ -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);
}
}