mirror of https://github.com/dswd/vpncloud.git
Fixed test cases
This commit is contained in:
parent
28a79f2d47
commit
fe036ded5f
|
@ -28,12 +28,12 @@ impl Protocol for Frame {
|
|||
let mut src = Vec::with_capacity(8);
|
||||
let mut dst = Vec::with_capacity(8);
|
||||
unsafe {
|
||||
ptr::copy_nonoverlapping(data.as_ptr(), src.as_mut_ptr(), 2);
|
||||
ptr::copy_nonoverlapping(src_data.as_ptr(), src[2..].as_mut_ptr(), 6);
|
||||
src.set_len(8);
|
||||
ptr::copy_nonoverlapping(data.as_ptr(), dst.as_mut_ptr(), 2);
|
||||
ptr::copy_nonoverlapping(dst_data.as_ptr(), dst[2..].as_mut_ptr(), 6);
|
||||
ptr::copy_nonoverlapping(data[pos..].as_ptr(), src.as_mut_ptr(), 2);
|
||||
ptr::copy_nonoverlapping(src_data.as_ptr(), src[2..].as_mut_ptr(), 6);
|
||||
dst.set_len(8);
|
||||
ptr::copy_nonoverlapping(data[pos..].as_ptr(), dst.as_mut_ptr(), 2);
|
||||
ptr::copy_nonoverlapping(dst_data.as_ptr(), dst[2..].as_mut_ptr(), 6);
|
||||
}
|
||||
Ok((Address(src), Address(dst)))
|
||||
} else {
|
||||
|
|
|
@ -258,7 +258,7 @@ fn encode_option_network_id() {
|
|||
let mut buf = [0; 1024];
|
||||
let size = encode(&options, &msg, &mut buf[..]);
|
||||
assert_eq!(size, 16);
|
||||
assert_eq!(&buf[..size], &[118,112,110,0,0,0,1,2,0,0,0,0,0,0,0,134]);
|
||||
assert_eq!(&buf[..size], &[118,112,110,0,0,0,1,3,0,0,0,0,0,0,0,134]);
|
||||
let (options2, msg2) = decode(&buf[..size]).unwrap();
|
||||
assert_eq!(options, options2);
|
||||
assert_eq!(msg, msg2);
|
||||
|
@ -271,8 +271,8 @@ fn encode_message_init() {
|
|||
let msg = Message::Init(addrs);
|
||||
let mut buf = [0; 1024];
|
||||
let size = encode(&options, &msg, &mut buf[..]);
|
||||
assert_eq!(size, 13);
|
||||
assert_eq!(&buf[..size], &[118,112,110,0,0,0,0,2,1,2,3,4,5]);
|
||||
assert_eq!(size, 9);
|
||||
assert_eq!(&buf[..size], &[118,112,110,0,0,0,0,2,0]);
|
||||
let (options2, msg2) = decode(&buf[..size]).unwrap();
|
||||
assert_eq!(options, options2);
|
||||
assert_eq!(msg, msg2);
|
||||
|
|
Loading…
Reference in New Issue