Remove more or less duplicate test cases for 2in9 buffer

This commit is contained in:
Chris
2018-10-22 15:43:50 +02:00
parent 8f0a2a98ad
commit 697a781ff2
8 changed files with 118 additions and 10 deletions
+41
View File
@@ -0,0 +1,41 @@
use epd2in9::{DEFAULT_BACKGROUND_COLOR, WIDTH, HEIGHT};
pub struct Buffer2in9 {
pub buffer: [u8; WIDTH as usize * HEIGHT as usize / 8],
}
impl Default for Buffer2in9 {
fn default() -> Self {
Buffer2in9 {
buffer: [
DEFAULT_BACKGROUND_COLOR.get_byte_value();
WIDTH as usize * HEIGHT as usize / 8
]
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use graphics::Display;
// test buffer length
#[test]
fn graphics_size() {
let mut buffer = Buffer2in9::default();
let display = Display::new(WIDTH, HEIGHT, &mut buffer.buffer);
assert_eq!(display.buffer().len(), 4736);
}
// test default background color on all bytes
#[test]
fn graphics_default() {
let mut buffer = Buffer2in9::default();
let display = Display::new(WIDTH, HEIGHT, &mut buffer.buffer);
for &byte in display.buffer() {
assert_eq!(byte, DEFAULT_BACKGROUND_COLOR.get_byte_value());
}
}
}
+3
View File
@@ -39,6 +39,9 @@ use traits::*;
use interface::DisplayInterface;
mod graphics;
pub use epd2in9::graphics::Buffer2in9;
/// EPD2in9 driver
///
pub struct EPD2in9<SPI, CS, BUSY, DC, RST> {