(tests) rcode parsing tests #22

Merged
mice_on_drugs merged 2 commits from p/ddidderr/parse_dns_header_rcodes_tests into master 2022-05-08 16:48:15 +02:00
Showing only changes of commit 951d0d7df8 - Show all commits

View File

@ -125,7 +125,7 @@ impl From<bool> for DNSMessageType {
}
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct DNSHeader {
/// used by the requester to match up replies to outstanding queries
pub id: u16,
@ -317,15 +317,13 @@ mod tests {
dns_query[3] = (rcode as u8) << 0;
let parse_result = DNSHeader::from_udp_datagram(&dns_query);
let parse_result_clone = parse_result.clone();
assert_eq!(
parse_result.err(),
Some(DNSParseError::DNSRCodeInvalid),
"query: {:02x?}, rcode: {}, parsed_rcode: {:?}",
parse_result,
Err(DNSParseError::DNSRCodeInvalid),
"query: {:02x?}, rcode: {}",
dns_query,
rcode,
parse_result_clone.map(|x| x.response_code).unwrap()
);
}
}