From 7cac67b0fcfc799103e5cc87712b72e8a197a61a Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Sun, 3 Apr 2022 21:03:45 -0700 Subject: [PATCH] Add more tests for println --- src/vga_buffer.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/vga_buffer.rs b/src/vga_buffer.rs index f64180b..b88aad9 100644 --- a/src/vga_buffer.rs +++ b/src/vga_buffer.rs @@ -168,3 +168,22 @@ lazy_static! { fn test_println_simple() { println!("Does this work?"); } + +#[test_case] +fn test_println_many() { + for _ in 0..200 { + println!("Test many output"); + } +} + +#[test_case] +fn test_println_output() { + let s = "Test string that fits on a single line"; + println!("{}", s); + for (i, c) in s.chars().enumerate() { + let screen_char_ptr = + &WRITER.lock().buffer.chars[BUFFER_HEIGHT - 2][i] as *const ScreenChar; + let screen_char = unsafe { core::ptr::read_volatile(screen_char_ptr) }; + assert_eq!(char::from(screen_char.ascii_char), c); + } +}