Skip to content

Commit 8842310

Browse files
committed
aml: tests: fix all clippy warnings
1 parent 5e4c150 commit 8842310

File tree

5 files changed

+27
-36
lines changed

5 files changed

+27
-36
lines changed

aml/src/name_object.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ mod tests {
252252
let mut context = crate::test_utils::make_test_context();
253253

254254
check_ok!(
255-
name_seg().parse(&[b'A', b'F', b'3', b'Z'], &mut context),
255+
name_seg().parse(b"AF3Z", &mut context),
256256
NameSeg([b'A', b'F', b'3', b'Z']),
257257
&[]
258258
);
@@ -292,12 +292,12 @@ mod tests {
292292
let mut context = crate::test_utils::make_test_context();
293293

294294
check_ok!(
295-
name_string().parse(&[b'^', b'A', b'B', b'C', b'D'], &mut context),
295+
name_string().parse(b"^ABCD", &mut context),
296296
AmlName::from_str("^ABCD").unwrap(),
297297
&[]
298298
);
299299
check_ok!(
300-
name_string().parse(&[b'^', b'^', b'^', b'A', b'B', b'C', b'D'], &mut context),
300+
name_string().parse(b"^^^ABCD", &mut context),
301301
AmlName::from_str("^^^ABCD").unwrap(),
302302
&[]
303303
);

aml/src/namespace.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -600,12 +600,12 @@ mod tests {
600600

601601
#[test]
602602
fn test_is_normal() {
603-
assert_eq!(AmlName::root().is_normal(), true);
604-
assert_eq!(AmlName::from_str("\\_SB.PCI0.VGA").unwrap().is_normal(), true);
605-
assert_eq!(AmlName::from_str("\\_SB.^PCI0.VGA").unwrap().is_normal(), false);
606-
assert_eq!(AmlName::from_str("\\^_SB.^^PCI0.VGA").unwrap().is_normal(), false);
607-
assert_eq!(AmlName::from_str("_SB.^^PCI0.VGA").unwrap().is_normal(), false);
608-
assert_eq!(AmlName::from_str("_SB.PCI0.VGA").unwrap().is_normal(), true);
603+
assert!(AmlName::root().is_normal());
604+
assert!(AmlName::from_str("\\_SB.PCI0.VGA").unwrap().is_normal());
605+
assert!(!AmlName::from_str("\\_SB.^PCI0.VGA").unwrap().is_normal());
606+
assert!(!AmlName::from_str("\\^_SB.^^PCI0.VGA").unwrap().is_normal());
607+
assert!(!AmlName::from_str("_SB.^^PCI0.VGA").unwrap().is_normal());
608+
assert!(AmlName::from_str("_SB.PCI0.VGA").unwrap().is_normal());
609609
}
610610

611611
#[test]
@@ -638,22 +638,22 @@ mod tests {
638638

639639
#[test]
640640
fn test_is_absolute() {
641-
assert_eq!(AmlName::root().is_absolute(), true);
642-
assert_eq!(AmlName::from_str("\\_SB.PCI0.VGA").unwrap().is_absolute(), true);
643-
assert_eq!(AmlName::from_str("\\_SB.^PCI0.VGA").unwrap().is_absolute(), true);
644-
assert_eq!(AmlName::from_str("\\^_SB.^^PCI0.VGA").unwrap().is_absolute(), true);
645-
assert_eq!(AmlName::from_str("_SB.^^PCI0.VGA").unwrap().is_absolute(), false);
646-
assert_eq!(AmlName::from_str("_SB.PCI0.VGA").unwrap().is_absolute(), false);
641+
assert!(AmlName::root().is_absolute());
642+
assert!(AmlName::from_str("\\_SB.PCI0.VGA").unwrap().is_absolute());
643+
assert!(AmlName::from_str("\\_SB.^PCI0.VGA").unwrap().is_absolute());
644+
assert!(AmlName::from_str("\\^_SB.^^PCI0.VGA").unwrap().is_absolute());
645+
assert!(!AmlName::from_str("_SB.^^PCI0.VGA").unwrap().is_absolute());
646+
assert!(!AmlName::from_str("_SB.PCI0.VGA").unwrap().is_absolute());
647647
}
648648

649649
#[test]
650650
fn test_search_rules_apply() {
651-
assert_eq!(AmlName::root().search_rules_apply(), false);
652-
assert_eq!(AmlName::from_str("\\_SB").unwrap().search_rules_apply(), false);
653-
assert_eq!(AmlName::from_str("^VGA").unwrap().search_rules_apply(), false);
654-
assert_eq!(AmlName::from_str("_SB.PCI0.VGA").unwrap().search_rules_apply(), false);
655-
assert_eq!(AmlName::from_str("VGA").unwrap().search_rules_apply(), true);
656-
assert_eq!(AmlName::from_str("_SB").unwrap().search_rules_apply(), true);
651+
assert!(!AmlName::root().search_rules_apply());
652+
assert!(!AmlName::from_str("\\_SB").unwrap().search_rules_apply());
653+
assert!(!AmlName::from_str("^VGA").unwrap().search_rules_apply());
654+
assert!(!AmlName::from_str("_SB.PCI0.VGA").unwrap().search_rules_apply());
655+
assert!(AmlName::from_str("VGA").unwrap().search_rules_apply());
656+
assert!(AmlName::from_str("_SB").unwrap().search_rules_apply());
657657
}
658658

659659
#[test]

aml/src/pkg_length.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ mod tests {
189189

190190
check_ok!(
191191
pkg_length()
192-
.feed(|length| crate::parser::take_to_end_of_pkglength(length))
192+
.feed(crate::parser::take_to_end_of_pkglength)
193193
.parse(&[0x05, 0x01, 0x02, 0x03, 0x04, 0xff, 0xff, 0xff], &mut context),
194194
&[0x01, 0x02, 0x03, 0x04],
195195
&[0xff, 0xff, 0xff]

aml/src/term_object.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ mod test {
10561056
);
10571057
check_ok_value!(
10581058
computational_data().parse(&[0xff, 0x98, 0xc3], &mut context),
1059-
AmlValue::Integer(u64::max_value()),
1059+
AmlValue::Integer(u64::MAX),
10601060
&[0x98, 0xc3]
10611061
);
10621062
check_ok_value!(

aml/src/test_utils.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,7 @@ pub(crate) fn crudely_cmp_values(a: &AmlValue, b: &AmlValue) -> bool {
125125
use crate::value::MethodCode;
126126

127127
match a {
128-
AmlValue::Uninitialized => match b {
129-
AmlValue::Uninitialized => true,
130-
_ => false,
131-
},
128+
AmlValue::Uninitialized => matches!(b, AmlValue::Uninitialized),
132129
AmlValue::Boolean(a) => match b {
133130
AmlValue::Boolean(b) => a == b,
134131
_ => false,
@@ -151,10 +148,7 @@ pub(crate) fn crudely_cmp_values(a: &AmlValue, b: &AmlValue) -> bool {
151148
}
152149
_ => false,
153150
},
154-
AmlValue::Device => match b {
155-
AmlValue::Device => true,
156-
_ => false,
157-
},
151+
AmlValue::Device => matches!(b, AmlValue::Device),
158152
AmlValue::Method { flags, code } => match b {
159153
AmlValue::Method { flags: b_flags, code: b_code } => {
160154
if flags != b_flags {
@@ -195,7 +189,7 @@ pub(crate) fn crudely_cmp_values(a: &AmlValue, b: &AmlValue) -> bool {
195189
AmlValue::Package(a) => match b {
196190
AmlValue::Package(b) => {
197191
for (a, b) in a.iter().zip(b) {
198-
if crudely_cmp_values(a, b) == false {
192+
if !crudely_cmp_values(a, b) {
199193
return false;
200194
}
201195
}
@@ -210,9 +204,6 @@ pub(crate) fn crudely_cmp_values(a: &AmlValue, b: &AmlValue) -> bool {
210204
}
211205
_ => false,
212206
},
213-
AmlValue::ThermalZone => match b {
214-
AmlValue::ThermalZone => true,
215-
_ => false,
216-
},
207+
AmlValue::ThermalZone => matches!(b, AmlValue::ThermalZone),
217208
}
218209
}

0 commit comments

Comments
 (0)