added test for LoginAck (#1890)

This commit is contained in:
Keiji, Yoshimi 2022-06-09 07:49:34 +09:00 committed by GitHub
parent 4e9bfb0b2d
commit 185c57d936
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ use crate::error::Error;
use crate::mssql::io::MssqlBufExt;
use crate::mssql::protocol::pre_login::Version;
#[allow(dead_code)]
#[derive(Debug)]
pub(crate) struct LoginAck {
pub(crate) interface: u8,
@ -37,3 +38,23 @@ impl LoginAck {
})
}
}
#[test]
fn test_get() {
#[rustfmt::skip]
let mut buf = Bytes::from_static(&[
0x36, 0, 1, 0x74, 0, 0, 4, 0x16, 0x4d, 0, 0x69, 0, 0x63, 0, 0x72, 0, 0x6f, 0, 0x73, 0, 0x6f, 0, 0x66, 0, 0x74, 0, 0x20, 0, 0x53, 0, 51, 0, 0x4c, 0, 0x20, 0, 0x53, 0, 0x65, 0, 0x72, 0, 0x76, 0, 0x65, 0, 0x72, 0, 0, 0, 0, 0, 0xf, 0, 0x10, 0x7f, 0xe3, 0x13, 0, 4, 4, 0x34, 0, 0x30, 0, 0x39, 0, 0x36, 0, 4, 0x34, 0, 0x30, 0, 0x39, 0, 0x36, 0, 0xfd, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
]);
let login_ack = LoginAck::get(&mut buf).unwrap();
assert_eq!(login_ack.interface, 1);
assert_eq!(login_ack.tds_version, 67108980);
assert_eq!(login_ack.program_version.major, 15);
assert_eq!(login_ack.program_version.minor, 0);
assert_eq!(login_ack.program_version.build, 4223);
assert_eq!(login_ack.program_version.sub_build, 0);
assert_eq!(login_ack.program_name, "Microsoft S3L Server\0\0");
}