small unit test for our SemLine struct
This commit is contained in:
parent
b1f432ef3f
commit
501a82760d
|
@ -2,11 +2,11 @@
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
|
|
||||||
// How many lines are there from HIGHEST to LOWEST
|
// How many lines are there from HIGHEST to LOWEST
|
||||||
const HEIGHT: usize = 32;
|
pub const HEIGHT: usize = 32;
|
||||||
// "Pixels" from left to right
|
// "Pixels" from left to right
|
||||||
const WIDTH: usize = 32;
|
pub const WIDTH: usize = 32;
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug,PartialEq)]
|
||||||
struct SemLine{
|
pub struct SemLine{
|
||||||
line: u32,
|
line: u32,
|
||||||
pixels:[u8;WIDTH]
|
pixels:[u8;WIDTH]
|
||||||
|
|
||||||
|
@ -20,9 +20,8 @@ mod tests {
|
||||||
fn test_serialize(){
|
fn test_serialize(){
|
||||||
let test_struct: SemLine = SemLine{line:0,pixels:[0;WIDTH]};
|
let test_struct: SemLine = SemLine{line:0,pixels:[0;WIDTH]};
|
||||||
let serialized = serde_json::to_string(&test_struct).unwrap();
|
let serialized = serde_json::to_string(&test_struct).unwrap();
|
||||||
let
|
let deserialized:SemLine = serde_json::from_str(&serialized).unwrap();
|
||||||
}
|
assert_eq!(test_struct,deserialized);
|
||||||
fn deserialize(){
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue