diff --git a/sqlx-core/src/mssql/protocol/return_value.rs b/sqlx-core/src/mssql/protocol/return_value.rs index e0f79667d7..1e7d331e21 100644 --- a/sqlx-core/src/mssql/protocol/return_value.rs +++ b/sqlx-core/src/mssql/protocol/return_value.rs @@ -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])) + ); +} diff --git a/sqlx-core/src/mssql/protocol/type_info.rs b/sqlx-core/src/mssql/protocol/type_info.rs index 3ed7af0ec5..d5136db285 100644 --- a/sqlx-core/src/mssql/protocol/type_info.rs +++ b/sqlx-core/src/mssql/protocol/type_info.rs @@ -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)); +}