Skip to content

Commit

Permalink
Add integration tests for pcap_loop (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wojtek242 authored Mar 15, 2024
1 parent d1494d0 commit 188acb1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/capture/activated/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,22 @@ fn test_filter() {
let result = capture.next_packet();
assert!(result.is_ok());
}

#[test]
fn read_packet_via_pcap_loop() {
let mut packets = 0;
let mut capture = capture_from_test_file("packet_snaplen_65535.pcap");
capture
.for_each(None, |_| {
packets += 1;
})
.unwrap();
assert_eq!(packets, 1);
}

#[test]
#[should_panic]
fn panic_in_pcap_loop() {
let mut capture = capture_from_test_file("packet_snaplen_65535.pcap");
capture.for_each(None, |_| panic!()).unwrap();
}

0 comments on commit 188acb1

Please sign in to comment.