Skip to content

Commit

Permalink
add test get ip V6 in TCP connection
Browse files Browse the repository at this point in the history
  • Loading branch information
konegoro committed Jan 4, 2024
1 parent 3b3be06 commit 82010dc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/client/tcp_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ mod tcp_connection_test{

use super::*;
use core::time;
use std::net::{IpAddr,Ipv4Addr};
use std::net::{IpAddr,Ipv4Addr,Ipv6Addr};
use crate::domain_name::DomainName;
use crate::message::type_qtype::Qtype;
use crate::message::class_qclass::Qclass;
Expand Down Expand Up @@ -135,6 +135,15 @@ mod tcp_connection_test{
assert_eq!(connection.get_ip(), IpAddr::V4(Ipv4Addr::new(192, 168, 0, 1)));
}

#[test]
fn get_ip_v6(){
let ip_address = IpAddr::V6(Ipv6Addr::new(0xc0, 0xa8, 0, 1, 0, 0, 0, 0));
let timeout = Duration::from_secs(100);
let connection = ClientTCPConnection::new(ip_address, timeout);
//check if the ip is the same
assert_eq!(connection.get_ip(), IpAddr::V6(Ipv6Addr::new(0xc0, 0xa8, 0, 1, 0, 0, 0, 0)));
}

//Setters and Getters test
#[test]
fn get_server_addr(){
Expand Down

0 comments on commit 82010dc

Please sign in to comment.