|
@@ -207,42 +207,3 @@ impl<'a> IpPayload for UdpRepr<'a> {
|
|
|
self.emit(&mut packet, &repr.src_addr(), &repr.dst_addr())
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-#[cfg(test)]
|
|
|
-mod test {
|
|
|
- use super::*;
|
|
|
-
|
|
|
- #[test]
|
|
|
- pub fn test_buffer() {
|
|
|
- let mut storage = vec![];
|
|
|
- for _ in 0..5 {
|
|
|
- storage.push(PacketBuffer::new(vec![0]))
|
|
|
- }
|
|
|
- let mut buffer = SocketBuffer::new(&mut storage[..]);
|
|
|
-
|
|
|
- assert_eq!(buffer.empty(), true);
|
|
|
- assert_eq!(buffer.full(), false);
|
|
|
- buffer.enqueue().unwrap().size = 1;
|
|
|
- assert_eq!(buffer.empty(), false);
|
|
|
- assert_eq!(buffer.full(), false);
|
|
|
- buffer.enqueue().unwrap().size = 2;
|
|
|
- buffer.enqueue().unwrap().size = 3;
|
|
|
- assert_eq!(buffer.dequeue().unwrap().size, 1);
|
|
|
- assert_eq!(buffer.dequeue().unwrap().size, 2);
|
|
|
- buffer.enqueue().unwrap().size = 4;
|
|
|
- buffer.enqueue().unwrap().size = 5;
|
|
|
- buffer.enqueue().unwrap().size = 6;
|
|
|
- buffer.enqueue().unwrap().size = 7;
|
|
|
- assert_eq!(buffer.enqueue().unwrap_err(), ());
|
|
|
- assert_eq!(buffer.empty(), false);
|
|
|
- assert_eq!(buffer.full(), true);
|
|
|
- assert_eq!(buffer.dequeue().unwrap().size, 3);
|
|
|
- assert_eq!(buffer.dequeue().unwrap().size, 4);
|
|
|
- assert_eq!(buffer.dequeue().unwrap().size, 5);
|
|
|
- assert_eq!(buffer.dequeue().unwrap().size, 6);
|
|
|
- assert_eq!(buffer.dequeue().unwrap().size, 7);
|
|
|
- assert_eq!(buffer.dequeue().unwrap_err(), ());
|
|
|
- assert_eq!(buffer.empty(), true);
|
|
|
- assert_eq!(buffer.full(), false);
|
|
|
- }
|
|
|
-}
|