Skip to content
Snippets Groups Projects
Verified Commit c4fd42d5 authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

chore: add more unit tests

parent c81ba40f
No related branches found
No related tags found
No related merge requests found
Pipeline #2850 failed
use crate::warnln;
#[derive(Clone, Copy, PartialEq, Eq)]
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum DmaMode {
General = 0x00,
HBlank = 0x01,
......@@ -116,3 +116,39 @@ impl Default for Dma {
Self::new()
}
}
#[cfg(test)]
mod tests {
use crate::dma::{Dma, DmaMode};
#[test]
fn test_dma_default() {
let dma = Dma::default();
assert_eq!(dma.active, false);
}
#[test]
fn test_dma_reset() {
let mut dma = Dma::new();
dma.source = 0x1234;
dma.destination = 0x5678;
dma.length = 0x9abc;
dma.mode = DmaMode::HBlank;
dma.active = true;
dma.reset();
assert_eq!(dma.source, 0x0);
assert_eq!(dma.destination, 0x0);
assert_eq!(dma.length, 0x0);
assert_eq!(dma.mode, DmaMode::General);
assert_eq!(dma.active, false);
}
#[test]
fn test_dma_set_active() {
let mut dma = Dma::new();
dma.set_active(true);
assert_eq!(dma.active, true);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment