Skip to content

Commit

Permalink
test: update rdlength assertions in resource_record tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joalopez1206 committed Sep 13, 2024
1 parent fac2c4c commit 4126b03
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/message/resource_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,8 @@ mod resource_record_test {
assert_eq!(u16::from(resource_record.rtype.clone()), 12);
assert_eq!(u16::from(resource_record.rclass.clone()), 1);
assert_eq!(resource_record.ttl, 0);
assert_eq!(resource_record.rdlength, 0);
// rdlength should be 1+4+1+3+1
assert_eq!(resource_record.rdlength, 1+4+1+3+1);
assert_eq!(
match resource_record.get_rdata() {
Rdata::PTR(val) => val.get_ptrdname().get_name(),
Expand Down Expand Up @@ -781,7 +782,8 @@ mod resource_record_test {
assert_eq!(u16::from(resource_record.rtype.clone()), 13);
assert_eq!(u16::from(resource_record.rclass.clone()), 1);
assert_eq!(resource_record.ttl, 0);
assert_eq!(resource_record.rdlength, 0);
//rd len is 18 because "INTEL-386"\0 + "Windows"\0 = 18
assert_eq!(resource_record.rdlength, 18);
assert_eq!(
match resource_record.get_rdata() {
Rdata::HINFO(val) => val.get_cpu(),
Expand Down Expand Up @@ -820,7 +822,8 @@ mod resource_record_test {
assert_eq!(u16::from(resource_record.rtype.clone()), 15);
assert_eq!(u16::from(resource_record.rclass.clone()), 1);
assert_eq!(resource_record.ttl, 0);
assert_eq!(resource_record.rdlength, 0);
// preference is 2 bytes and exchange is 1+5+1+7+1+3+1 bytes
assert_eq!(resource_record.rdlength, 21);
assert_eq!(
match resource_record.get_rdata() {
Rdata::MX(val) => val.get_preference(),
Expand Down Expand Up @@ -848,7 +851,8 @@ mod resource_record_test {
assert_eq!(u16::from(resource_record.rtype.clone()), 16);
assert_eq!(u16::from(resource_record.rclass.clone()), 1);
assert_eq!(resource_record.ttl, 0);
assert_eq!(resource_record.rdlength, 0);
// rdlength should be "dcc"\0 + "test"\0 = 9
assert_eq!(resource_record.rdlength, 9);
assert_eq!(
match resource_record.get_rdata() {
Rdata::TXT(val) => val.get_text(),
Expand Down Expand Up @@ -950,13 +954,8 @@ mod resource_record_test {
#[test]
fn set_and_get_rdlength_test() {
let txt_rdata = Rdata::TXT(TxtRdata::new(vec!["dcc".to_string()]));
let mut resource_record = ResourceRecord::new(txt_rdata);
assert_eq!(resource_record.get_rdlength(), 0);

resource_record.set_rdlength(3 as u16);

let rdlength = resource_record.get_rdlength();
assert_eq!(rdlength, 3 as u16);
let resource_record = ResourceRecord::new(txt_rdata);
assert_eq!(resource_record.get_rdlength(), 4);
}

#[test]
Expand Down

0 comments on commit 4126b03

Please sign in to comment.