Skip to content

Commit 6edb5d8

Browse files
committed
test(encode): add tests for domain_name_without_compression
1 parent eb01099 commit 6edb5d8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/encode/domain_name.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,32 @@ impl_encode!(
114114
domain_name_without_compression,
115115
encode_without_compression
116116
);
117+
118+
#[test]
119+
fn domain_name_without_compression_1() {
120+
let domain_name: DomainName = "example.org.".parse().unwrap();
121+
let mut encoder = Encoder::default();
122+
encoder
123+
.domain_name_without_compression(&domain_name)
124+
.unwrap();
125+
encoder
126+
.domain_name_without_compression(&domain_name)
127+
.unwrap();
128+
assert_eq!(
129+
encoder.bytes,
130+
&b"\x07example\x03org\0\x07example\x03org\0"[..]
131+
);
132+
}
133+
134+
#[test]
135+
fn domain_name_without_compression_2() {
136+
let domain_name = DomainName::default();
137+
let mut encoder = Encoder::default();
138+
encoder
139+
.domain_name_without_compression(&domain_name)
140+
.unwrap();
141+
encoder
142+
.domain_name_without_compression(&domain_name)
143+
.unwrap();
144+
assert_eq!(encoder.bytes, &b"\0\0"[..]);
145+
}

0 commit comments

Comments
 (0)