Construct a vga buffer for testing

This commit is contained in:
Philipp Oppermann
2019-01-25 13:31:06 +01:00
parent 76a65ca3ee
commit a15e01f2eb
3 changed files with 48 additions and 0 deletions

View File

@@ -140,3 +140,34 @@ pub fn _print(args: fmt::Arguments) {
use core::fmt::Write;
WRITER.lock().write_fmt(args).unwrap();
}
#[cfg(test)]
mod test {
use super::*;
fn construct_writer() -> Writer {
use std::boxed::Box;
let buffer = construct_buffer();
Writer {
column_position: 0,
color_code: ColorCode::new(Color::Blue, Color::Magenta),
buffer: Box::leak(Box::new(buffer)),
}
}
fn construct_buffer() -> Buffer {
use array_init::array_init;
Buffer {
chars: array_init(|_| array_init(|_| Volatile::new(empty_char()))),
}
}
fn empty_char() -> ScreenChar {
ScreenChar {
ascii_character: b' ',
color_code: ColorCode::new(Color::Green, Color::Brown),
}
}
}