Use result for test

This commit is contained in:
Tobias Ottenweller 2022-04-03 20:56:54 +02:00 committed by ddidderr
parent 0dc41ef845
commit 00ac8cbb4f
Signed by: ddidderr
GPG Key ID: 3841F1C27E6F0E14

View File

@ -245,7 +245,7 @@ mod tests {
} }
#[test] #[test]
fn parse_dns_header_opcode_valid() { fn parse_dns_header_opcode_valid() -> Result<(), DNSParseError> {
let mut dns_query = [ let mut dns_query = [
0xff, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
]; ];
@ -261,10 +261,8 @@ mod tests {
for (idx, opcode) in valid_opcodes.iter().enumerate() { for (idx, opcode) in valid_opcodes.iter().enumerate() {
dns_query[2] = opcode << 3; dns_query[2] = opcode << 3;
let parse_result = DNSHeader::from_udp_datagram(&dns_query); let parse_result = DNSHeader::from_udp_datagram(&dns_query);
assert_eq!( assert_eq!(parse_result?.opcode, valid_parsed_opcodes[idx]);
parse_result.map(|x| x.opcode), }
Ok(valid_parsed_opcodes[idx]) Ok(())
);
}
} }
} }