Skip to content

Commit c8e92b4

Browse files
committed
test sps
1 parent ae0eb46 commit c8e92b4

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

tests/src/block.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,18 @@ impl From<u8> for Block {
1717
}
1818
}
1919
}
20+
21+
impl From<char> for Block {
22+
fn from(value: char) -> Self {
23+
match value {
24+
'T' => Block::T,
25+
'J' => Block::J,
26+
'Z' => Block::Z,
27+
'O' => Block::O,
28+
'S' => Block::S,
29+
'L' => Block::L,
30+
'I' => Block::I,
31+
_ => Block::Unknown(value as u8),
32+
}
33+
}
34+
}

tests/src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ struct TestOptions {
2424
fn main() {
2525
let options = TestOptions::parse_args_default_or_exit();
2626

27+
// run SPS tests
2728
if options.test {
29+
sps::test();
30+
println!("sps works!");
2831
pushdown::test();
2932
println!("pushdown works!");
3033
}
3134

35+
// print SPS sequences
3236
if options.sps_qty > 0 {
3337
let mut blocks = sps::SPS::new();
3438

tests/src/sps.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use crate::{block, labels, util};
12
use rusticnes_core::nes::NesState;
2-
use crate::{labels, util, block};
33

44
pub struct SPS {
55
emu: NesState,
@@ -29,3 +29,27 @@ impl SPS {
2929
self.emu.memory.iram_raw[labels::get("spawnID") as usize].into()
3030
}
3131
}
32+
33+
pub fn test() {
34+
let mut blocks = SPS::new();
35+
36+
blocks.set_input((0x10, 0x10, 0x10));
37+
"ZJOTLTZJLZJSZISIJOLITJSILZJILITSISZOITIZSZJLLTIOZJZSZISIJZTIZJTSOJSJISJOOTSJTOTZSZTZSLTZTOTSIZJZIJIL".chars().for_each(|block| {
38+
assert_eq!(blocks.next(), block.into());
39+
});
40+
41+
blocks.set_input((0x12, 0x34, 0x56));
42+
"ZTZIJIJOZTSOSZJZOSLIOIJIJSTZSTTJISSTOIZJITJOZJITSOSZSJLTISJOITTLSLJTZTZOZSLJTJZSLTSOTLOJLSJSJTJILOJS".chars().for_each(|block| {
43+
assert_eq!(blocks.next(), block.into());
44+
});
45+
46+
blocks.set_input((0x87, 0xAB, 0x12));
47+
"OZIJSOTZSJTSTJZLOLJOJISOZOIOZJITILSSJZLOIJSTITLSOJILTSOOLZOOIJOZLTLSISIJIJTOLSIJILSLOLJLTOSOSLOIZSIS".chars().for_each(|block| {
48+
assert_eq!(blocks.next(), block.into());
49+
});
50+
51+
blocks.set_input((0x13, 0x37, 0x02));
52+
"OJSTZSIOLSIJTSZILJZJJLZLISISJTLZTSZTJOJOSJSZLITJOIOTITILTOSTJSZTSOOIOJSIITLJOZSIOJOTZTLJLIOJLITSSLSLIJIIOLOISLZJLIJJTIZIJOJISLTIJTOTZIOILSTTLTZIZJSOLOZOZOLOTZTZOTZOSIOTJJTSIZSOLTOLIZSOZOTZISLJTSZLOISO".chars().for_each(|block| {
53+
assert_eq!(blocks.next(), block.into());
54+
});
55+
}

0 commit comments

Comments
 (0)