Update tests
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
/target
|
/target
|
||||||
.idea
|
.idea
|
||||||
/roms
|
/roms
|
||||||
|
.DS_Store
|
||||||
|
@@ -170,7 +170,6 @@ impl Instruction {
|
|||||||
let x = (instruction & 0xf00) >> 8;
|
let x = (instruction & 0xf00) >> 8;
|
||||||
Instruction::GetKey(x as usize)
|
Instruction::GetKey(x as usize)
|
||||||
}
|
}
|
||||||
//TODO add tests from here
|
|
||||||
0xF if (instruction & 0xff) == 0x29 => {
|
0xF if (instruction & 0xff) == 0x29 => {
|
||||||
let x = (instruction & 0xf00) >> 8;
|
let x = (instruction & 0xf00) >> 8;
|
||||||
Instruction::SetIndexToFontCharacter(x as usize)
|
Instruction::SetIndexToFontCharacter(x as usize)
|
||||||
|
@@ -29,6 +29,8 @@ mod util;
|
|||||||
mod sdl_adapters;
|
mod sdl_adapters;
|
||||||
mod rom;
|
mod rom;
|
||||||
|
|
||||||
|
const WINDOW_TITLE: &str = "porcel8";
|
||||||
|
|
||||||
fn main() -> EmulatorResult<()> {
|
fn main() -> EmulatorResult<()> {
|
||||||
SimpleLogger::new().with_level(LevelFilter::Info).env().init().unwrap();
|
SimpleLogger::new().with_level(LevelFilter::Info).env().init().unwrap();
|
||||||
let Porcel8ProgramArgs { filename, new_chip8_behaviour, draw_scale, halt_on_invalid } = Porcel8ProgramArgs::parse();
|
let Porcel8ProgramArgs { filename, new_chip8_behaviour, draw_scale, halt_on_invalid } = Porcel8ProgramArgs::parse();
|
||||||
@@ -144,7 +146,7 @@ fn try_initiate_sdl(draw_scale: f32) -> EmulatorResult<(WindowCanvas, EventPump,
|
|||||||
let window_width = (Device::FRAME_BUFFER_WIDTH as f32 * draw_scale) as u32;
|
let window_width = (Device::FRAME_BUFFER_WIDTH as f32 * draw_scale) as u32;
|
||||||
let window_height = (Device::FRAME_BUFFER_HEIGHT as f32 * draw_scale) as u32;
|
let window_height = (Device::FRAME_BUFFER_HEIGHT as f32 * draw_scale) as u32;
|
||||||
|
|
||||||
let window = video_subsystem.window("porcel8", window_width, window_height)
|
let window = video_subsystem.window(WINDOW_TITLE, window_width, window_height)
|
||||||
.position_centered()
|
.position_centered()
|
||||||
.build()?;
|
.build()?;
|
||||||
let mut canvas = window.into_canvas().build()?;
|
let mut canvas = window.into_canvas().build()?;
|
||||||
|
@@ -60,3 +60,19 @@ impl SdlKeyboardAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests{
|
||||||
|
use crate::device::keyboard::Key;
|
||||||
|
|
||||||
|
use super::SdlKeyboardAdapter;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_keycode_to_key(){
|
||||||
|
assert_eq!(Some(Key::K7), SdlKeyboardAdapter::keycode_to_key(sdl2::keyboard::Keycode::A));
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn test_keycode_to_key_no_key(){
|
||||||
|
assert_eq!(None, SdlKeyboardAdapter::keycode_to_key(sdl2::keyboard::Keycode::L));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user