From 501a82760d5b3a93468e1ea5ba765c3a8770bf48 Mon Sep 17 00:00:00 2001 From: Robert Schauklies Date: Sat, 11 Jan 2025 16:20:31 +0100 Subject: [PATCH] small unit test for our SemLine struct --- beamer/libs/semserialize/src/lib.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/beamer/libs/semserialize/src/lib.rs b/beamer/libs/semserialize/src/lib.rs index 912e3a8..dbc93e8 100644 --- a/beamer/libs/semserialize/src/lib.rs +++ b/beamer/libs/semserialize/src/lib.rs @@ -2,11 +2,11 @@ use serde::{Serialize, Deserialize}; // How many lines are there from HIGHEST to LOWEST -const HEIGHT: usize = 32; +pub const HEIGHT: usize = 32; // "Pixels" from left to right -const WIDTH: usize = 32; -#[derive(Serialize, Deserialize, Debug)] -struct SemLine{ +pub const WIDTH: usize = 32; +#[derive(Serialize, Deserialize, Debug,PartialEq)] +pub struct SemLine{ line: u32, pixels:[u8;WIDTH] @@ -20,9 +20,8 @@ mod tests { fn test_serialize(){ let test_struct: SemLine = SemLine{line:0,pixels:[0;WIDTH]}; let serialized = serde_json::to_string(&test_struct).unwrap(); - let - } - fn deserialize(){ + let deserialized:SemLine = serde_json::from_str(&serialized).unwrap(); + assert_eq!(test_struct,deserialized); } }