|
@@ -225,26 +225,21 @@ mod tests {
|
|
|
fn test_name_path() {
|
|
|
let mut context = AmlContext::new();
|
|
|
|
|
|
- check_err!(name_path().parse(&[], &mut context), AmlError::UnexpectedEndOfStream, &[]);
|
|
|
- check_ok!(name_path().parse(&[0x00], &mut context), String::from(""), &[]);
|
|
|
- check_ok!(name_path().parse(&[0x00, 0x00], &mut context), String::from(""), &[0x00]);
|
|
|
- // TODO: this failure is actually a symptom of `choice!` not working quite correctly. When
|
|
|
- // the dual_name_path parser fails (this is one, but is too short), it carries on and then
|
|
|
- // returns a confusing error: `UnexpectedByte(0x2e)`. Not sure how the best way to go about
|
|
|
- // fixing that is.
|
|
|
- //
|
|
|
- // For now, we know about this corner case, so altering the unit-test for now.
|
|
|
+ check_err!(name_path().parse(&[], &mut context), AmlError::NoParsersCouldParse, &[]);
|
|
|
+ check_ok!(name_path().parse(&[0x00], &mut context), alloc::vec![], &[]);
|
|
|
+ check_ok!(name_path().parse(&[0x00, 0x00], &mut context), alloc::vec![], &[0x00]);
|
|
|
check_err!(
|
|
|
name_path().parse(&[0x2e, b'A'], &mut context),
|
|
|
- AmlError::UnexpectedByte(0x2e),
|
|
|
- // TODO: this is the correct error
|
|
|
- // AmlError::UnexpectedEndOfStream,
|
|
|
+ AmlError::NoParsersCouldParse,
|
|
|
&[0x2e, b'A']
|
|
|
);
|
|
|
check_ok!(
|
|
|
name_path()
|
|
|
.parse(&[0x2e, b'A', b'B', b'C', b'D', b'E', b'_', b'F', b'G'], &mut context),
|
|
|
- String::from("ABCDE_FG"),
|
|
|
+ alloc::vec![
|
|
|
+ NameComponent::Segment(NameSeg([b'A', b'B', b'C', b'D'])),
|
|
|
+ NameComponent::Segment(NameSeg([b'E', b'_', b'F', b'G']))
|
|
|
+ ],
|
|
|
&[]
|
|
|
);
|
|
|
}
|