Commit 320d8e6e authored by Nawasan Wisitsingkhon's avatar Nawasan Wisitsingkhon

add unit testing

parent 7d9df7b0
......@@ -7,7 +7,7 @@ To understand The software-defined networking well, I trying to create a simple
## TODOs
- [x] design structure of code and working.
- [ ] test case. ([Read docs](https://doc.rust-lang.org/book/ch11-01-writing-tests.html))
- [x] test case. ([Read docs](https://doc.rust-lang.org/book/ch11-01-writing-tests.html))
- [ ] write more description in README.
## Learning resources
......
#[cfg(test)]
mod tests {
use tenjin::{
openflow::{
controller_frame::ControllerFrame, ofp_manager::OfpMsgEvent, ofp_v1_0::Openflow10,
},
Controller,
};
#[test]
fn test_header_v1_0_parser() {
let ofp_header_bytes: Vec<u8> = vec![1, 0, 0, 8, 0, 0, 0, 1];
let controller = Controller::new(Openflow10::new());
let ofp = controller.get_ofp();
let header = ofp.header_parse(&ofp_header_bytes);
assert_eq!(header.version(), 1);
assert_eq!(header.message(), 0);
assert_eq!(header.length(), 8);
assert_eq!(header.xid(), 1);
}
}
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