Commit 61401812 authored by Nawasan Wisitsingkhon's avatar Nawasan Wisitsingkhon

add test case: header marshal

parent 320d8e6e
......@@ -2,7 +2,9 @@
mod tests {
use tenjin::{
openflow::{
controller_frame::ControllerFrame, ofp_manager::OfpMsgEvent, ofp_v1_0::Openflow10,
controller_frame::ControllerFrame,
ofp_manager::{OfpMsg, OfpMsgEvent},
ofp_v1_0::Openflow10,
},
Controller,
};
......@@ -13,7 +15,6 @@ mod tests {
let controller = Controller::new(Openflow10::new());
let ofp = controller.get_ofp();
let header = ofp.header_parse(&ofp_header_bytes);
assert_eq!(header.version(), 1);
......@@ -21,4 +22,16 @@ mod tests {
assert_eq!(header.length(), 8);
assert_eq!(header.xid(), 1);
}
#[test]
fn test_header_v1_0_marshal() {
let ofp_header_bytes: Vec<u8> = vec![1, 0, 0, 8, 0, 0, 0, 0];
let controller = Controller::new(Openflow10::new());
let ofp = controller.get_ofp();
let ofp_header = ofp.header(ofp.msg_usize(OfpMsg::Hello) as u8, 0, 0);
let mut bytes: Vec<u8> = Vec::new();
ofp_header.marshal(&mut bytes);
assert_eq!(ofp_header_bytes, bytes);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment