Skip to content

Commit

Permalink
add unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Arikato111 committed May 11, 2024
1 parent 7d9df7b commit 320d8e6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions tests/headers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#[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);
}
}

0 comments on commit 320d8e6

Please sign in to comment.