Add a couple of regression tests for encoding

This commit is contained in:
Ryan Leckey 2019-07-26 09:22:50 -07:00
parent 7c70445e3d
commit 742946a66a
2 changed files with 22 additions and 0 deletions

View File

@ -15,3 +15,14 @@ pub fn execute(buf: &mut Vec<u8>, portal: &str, limit: i32) {
// limit
buf.extend_from_slice(&limit.to_be_bytes());
}
#[cfg(test)]
mod tests {
#[test]
fn it_encodes_execute() {
let mut buf = Vec::new();
super::execute(&mut buf, "", 0);
assert_eq!(&*buf, b"E\0\0\0\t\0\0\0\0\0");
}
}

View File

@ -5,3 +5,14 @@ pub fn sync(buf: &mut Vec<u8>) {
buf.push(b'S');
buf.extend_from_slice(&4_i32.to_be_bytes());
}
#[cfg(test)]
mod tests {
#[test]
fn it_encodes_sync() {
let mut buf = Vec::new();
super::sync(&mut buf);
assert_eq!(&*buf, b"S\0\0\0\x04");
}
}