Skip to content

Commit

Permalink
add: decrement work counter test
Browse files Browse the repository at this point in the history
  • Loading branch information
justRkive committed Dec 3, 2024
1 parent d801d75 commit 0c6d18f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/async_resolver/state_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,29 @@ mod state_block_tests {
assert_eq!(state_block.get_current_server_index(), 0);
}

#[test]
fn decrement_work_counter() {
let ip_addr = IpAddr::V4(Ipv4Addr::new(192, 168, 0, 1));
let port = 53;
let key = String::from("key");
let algorithm = String::from("algorithm");
let udp_connection = ClientUDPConnection::new_default(ip_addr, Duration::from_secs(100));
let tcp_connection = ClientTCPConnection::new_default(ip_addr, Duration::from_secs(100));
let info = ServerInfo::new(ip_addr, port, key, algorithm, udp_connection, tcp_connection);

let info_arc = Arc::new(info);
let servers = vec![info_arc];

let mut state_block = StateBlock::new(5, 2, servers);
assert_eq!(state_block.get_work_counter(), 5);

state_block.decrement_work_counter();
assert_eq!(state_block.get_work_counter(), 4);

state_block.decrement_work_counter();
assert_eq!(state_block.get_work_counter(), 3);
}



}

0 comments on commit 0c6d18f

Please sign in to comment.