From c7e83c2b29bb6eb38c6c2ae6811577f81383f66c Mon Sep 17 00:00:00 2001 From: wangfenjin Date: Sat, 25 Sep 2021 10:42:22 +0800 Subject: [PATCH] add test for uint Change-Id: I2a23cae7524c239a2c7d9b85e4ba6f999d9beabf --- src/types/from_sql.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/types/from_sql.rs b/src/types/from_sql.rs index 575dd4ce..3257cc37 100644 --- a/src/types/from_sql.rs +++ b/src/types/from_sql.rs @@ -298,6 +298,21 @@ mod test { Ok(()) } + #[test] + fn test_unsigned_integer() -> Result<()> { + let db = Connection::open_in_memory()?; + let sql = "BEGIN; + CREATE TABLE unsigned_int (u1 utinyint, u2 usmallint, u4 uinteger, u8 ubigint); + INSERT INTO unsigned_int VALUES (255, 65535, 4294967295, 18446744073709551615); + END;"; + db.execute_batch(sql)?; + let v = db.query_row("SELECT * FROM unsigned_int", [], |row| { + <(u8, u16, u32, u64)>::try_from(row) + })?; + assert_eq!(v, (255, 65535, 4294967295, 18446744073709551615)); + Ok(()) + } + #[test] fn test_integral_ranges() -> Result<()> { let db = Connection::open_in_memory()?;