mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-10-02 23:35:20 +00:00
added test for mssql ReturnValue (#1892)
* added test for mssql ReturnValue * fixed warnings: unused import: `DataType`
This commit is contained in:
parent
1f91724927
commit
3cfa734b50
@ -4,8 +4,11 @@ use bytes::{Buf, Bytes};
|
||||
use crate::error::Error;
|
||||
use crate::mssql::io::MssqlBufExt;
|
||||
use crate::mssql::protocol::col_meta_data::Flags;
|
||||
#[cfg(test)]
|
||||
use crate::mssql::protocol::type_info::DataType;
|
||||
use crate::mssql::protocol::type_info::TypeInfo;
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct ReturnValue {
|
||||
param_ordinal: u16,
|
||||
@ -48,3 +51,27 @@ impl ReturnValue {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get() {
|
||||
#[rustfmt::skip]
|
||||
let mut buf = Bytes::from_static(&[
|
||||
0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0x26, 4, 4, 1, 0, 0, 0, 0xfe, 0, 0, 0xe0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
]);
|
||||
|
||||
let return_value = ReturnValue::get(&mut buf).unwrap();
|
||||
|
||||
assert_eq!(return_value.param_ordinal, 0);
|
||||
assert_eq!(return_value.param_name, "");
|
||||
assert_eq!(
|
||||
return_value.status,
|
||||
ReturnValueStatus::from_bits_truncate(1)
|
||||
);
|
||||
assert_eq!(return_value.user_type, 0);
|
||||
assert_eq!(return_value.flags, Flags::from_bits_truncate(0));
|
||||
assert_eq!(return_value.type_info, TypeInfo::new(DataType::IntN, 4));
|
||||
assert_eq!(
|
||||
return_value.value,
|
||||
Some(Bytes::from_static(&[0x01, 0, 0, 0]))
|
||||
);
|
||||
}
|
||||
|
@ -660,3 +660,14 @@ impl Collation {
|
||||
buf.push(self.sort);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get() {
|
||||
#[rustfmt::skip]
|
||||
let mut buf = Bytes::from_static(&[
|
||||
0x26, 4, 4, 1, 0, 0, 0, 0xfe, 0, 0, 0xe0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
]);
|
||||
|
||||
let type_info = TypeInfo::get(&mut buf).unwrap();
|
||||
assert_eq!(type_info, TypeInfo::new(DataType::IntN, 4));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user