Skip to content

Commit 3b3be06

Browse files
committed
add test get ip V4 in TCP connection
1 parent b5af86d commit 3b3be06

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/client/tcp_connection.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ impl ClientTCPConnection {
105105
mod tcp_connection_test{
106106

107107
use super::*;
108+
use core::time;
108109
use std::net::{IpAddr,Ipv4Addr};
109110
use crate::domain_name::DomainName;
110111
use crate::message::type_qtype::Qtype;
@@ -125,6 +126,15 @@ mod tcp_connection_test{
125126
assert_eq!(_conn_new.get_timeout(), Duration::from_secs(100));
126127
}
127128

129+
#[test]
130+
fn get_ip_v4(){
131+
let ip_address = IpAddr::V4(Ipv4Addr::new(192, 168, 0, 1));
132+
let timeout = Duration::from_secs(100);
133+
let connection = ClientTCPConnection::new(ip_address, timeout);
134+
//check if the ip is the same
135+
assert_eq!(connection.get_ip(), IpAddr::V4(Ipv4Addr::new(192, 168, 0, 1)));
136+
}
137+
128138
//Setters and Getters test
129139
#[test]
130140
fn get_server_addr(){

0 commit comments

Comments
 (0)