mirror of
https://github.com/cccb/servicepoint.git
synced 2025-01-18 18:10:14 +01:00
more tests
This commit is contained in:
parent
b08fd97066
commit
894de966bc
|
@ -304,4 +304,16 @@ mod tests {
|
|||
assert_eq!(None, vec.get_ref_mut_optional(2, 2));
|
||||
assert_eq!(Some(&mut 5), vec.get_ref_mut_optional(0, 0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn optional() {
|
||||
let mut grid = ByteGrid::load(2, 2, &[0, 1, 2, 3]);
|
||||
grid.set_optional(0, 0, 5);
|
||||
grid.set_optional(-1, 0, 8);
|
||||
grid.set_optional(0, 8, 42);
|
||||
assert_eq!(grid.data, [5, 1, 2, 3]);
|
||||
|
||||
assert_eq!(grid.get_optional(0, 0), Some(5));
|
||||
assert_eq!(grid.get_optional(0, 8), None);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,4 +69,10 @@ mod tests {
|
|||
let p = Packet::try_from(&*data).unwrap();
|
||||
assert_eq!(p, Packet(Header(0, 1, 2, 3, 4), vec![42u8; 23]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn too_small() {
|
||||
let data = vec![0u8; 4];
|
||||
assert_eq!(Packet::try_from(data.as_slice()), Err(()))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -281,4 +281,12 @@ mod tests {
|
|||
}
|
||||
assert_eq!(grid.data_ref(), [0xAA, 0xAA]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn data_ref_mut() {
|
||||
let mut grid = PixelGrid::new(8, 2);
|
||||
let data = grid.data_ref_mut();
|
||||
data[1] = 0x0F;
|
||||
assert!(grid.get(7, 1));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue