Skip to content

Commit

Permalink
Make dfa decoding tests strict
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Young <sean@mess.org>
  • Loading branch information
seanyoung committed May 4, 2024
1 parent ba41680 commit 59f1fe1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions irp/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ fn decode_all() {
println!("trying {}", protocol.name);

if protocol.name == "NEC-Shirriff" {
protocol.irp = "{38.4k,msb,564}<1,-1|1,-3>(16,-8,data:length,1,^108m) [data:0..UINT32_MAX,length:1..63]".into();
protocol.irp = "{38.4k,msb,564}<1,-1|1,-3>(16,-8,data:length,1,^128m) [data:0..UINT32_MAX,length:1..63]".into();
}

let irp = Irp::parse(&protocol.irp).unwrap();
Expand Down Expand Up @@ -500,11 +500,11 @@ fn decode_all() {
let mut decodes = Vec::new();

for data in InfraredData::from_u32_slice(&msg.raw) {
// TODO: fix DFA decoding here
decoder.nfa_input(data, &nfa, |ev, res| decodes.push((ev, res)));
decoder.dfa_input(data, &dfa, |ev, res| decodes.push((ev, res)));
}

let mut ok = false;
// if nothing decoded, we fail to decode
let mut ok = !decodes.is_empty();

while let Some((ev, mut res)) = decodes.pop() {
if ev == Event::Down && res.is_empty() {
Expand Down Expand Up @@ -541,9 +541,8 @@ fn decode_all() {
}
}

if params == res {
ok = true;
} else {
if params != res {
ok = false;
failed_protocols.insert(&protocol.name);
}
}
Expand Down Expand Up @@ -572,7 +571,8 @@ fn decode_all() {
println!("tests: {total_tests} fails: {fails}");
println!("Failed protocols: {failed_protocols:?}");

assert_eq!(fails, 0);
let expected_failures = HashSet::from(["Pioneer-2Part", "NRC17", "Epson", "F12x", "Roku-8bit"]);
assert_eq!(failed_protocols, expected_failures);
}

#[test]
Expand Down

0 comments on commit 59f1fe1

Please sign in to comment.