mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 08:49:27 +08:00
Add more explicit types in unit tests.
This commit is contained in:
parent
186da8d9ad
commit
60e1f3c02f
@ -258,7 +258,11 @@ mod test {
|
|||||||
{
|
{
|
||||||
let mut stmt = db.prepare_cached(sql).unwrap();
|
let mut stmt = db.prepare_cached(sql).unwrap();
|
||||||
assert_eq!(1i32,
|
assert_eq!(1i32,
|
||||||
stmt.query_map(&[], |r| r.get(0)).unwrap().next().unwrap().unwrap());
|
stmt.query_map::<i32, _>(&[], |r| r.get(0))
|
||||||
|
.unwrap()
|
||||||
|
.next()
|
||||||
|
.unwrap()
|
||||||
|
.unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
db.execute_batch(r#"
|
db.execute_batch(r#"
|
||||||
|
@ -1333,7 +1333,7 @@ mod test {
|
|||||||
db.execute("INSERT INTO foo(x) VALUES (?)", &[&2i32]).unwrap());
|
db.execute("INSERT INTO foo(x) VALUES (?)", &[&2i32]).unwrap());
|
||||||
|
|
||||||
assert_eq!(3i32,
|
assert_eq!(3i32,
|
||||||
db.query_row("SELECT SUM(x) FROM foo", &[], |r| r.get(0)).unwrap());
|
db.query_row::<i32, _>("SELECT SUM(x) FROM foo", &[], |r| r.get(0)).unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -1449,7 +1449,7 @@ mod test {
|
|||||||
db.execute_batch(sql).unwrap();
|
db.execute_batch(sql).unwrap();
|
||||||
|
|
||||||
assert_eq!(10i64,
|
assert_eq!(10i64,
|
||||||
db.query_row("SELECT SUM(x) FROM foo", &[], |r| r.get(0))
|
db.query_row::<i64, _>("SELECT SUM(x) FROM foo", &[], |r| r.get(0))
|
||||||
.unwrap());
|
.unwrap());
|
||||||
|
|
||||||
let result: Result<i64> = db.query_row("SELECT x FROM foo WHERE x > 5", &[], |r| r.get(0));
|
let result: Result<i64> = db.query_row("SELECT x FROM foo WHERE x > 5", &[], |r| r.get(0));
|
||||||
|
@ -229,7 +229,7 @@ mod test {
|
|||||||
1);
|
1);
|
||||||
|
|
||||||
assert_eq!(3i32,
|
assert_eq!(3i32,
|
||||||
db.query_row_named("SELECT SUM(x) FROM foo WHERE x > :x",
|
db.query_row_named::<i32, _>("SELECT SUM(x) FROM foo WHERE x > :x",
|
||||||
&[(":x", &0i32)],
|
&[(":x", &0i32)],
|
||||||
|r| r.get(0))
|
|r| r.get(0))
|
||||||
.unwrap());
|
.unwrap());
|
||||||
@ -246,7 +246,7 @@ mod test {
|
|||||||
stmt.execute_named(&[(":name", &"one")]).unwrap();
|
stmt.execute_named(&[(":name", &"one")]).unwrap();
|
||||||
|
|
||||||
assert_eq!(1i32,
|
assert_eq!(1i32,
|
||||||
db.query_row_named("SELECT COUNT(*) FROM test WHERE name = :name",
|
db.query_row_named::<i32, _>("SELECT COUNT(*) FROM test WHERE name = :name",
|
||||||
&[(":name", &"one")],
|
&[(":name", &"one")],
|
||||||
|r| r.get(0))
|
|r| r.get(0))
|
||||||
.unwrap());
|
.unwrap());
|
||||||
|
@ -427,7 +427,8 @@ mod test {
|
|||||||
{
|
{
|
||||||
let tx = db.transaction().unwrap();
|
let tx = db.transaction().unwrap();
|
||||||
assert_eq!(2i32,
|
assert_eq!(2i32,
|
||||||
tx.query_row("SELECT SUM(x) FROM foo", &[], |r| r.get(0)).unwrap());
|
tx.query_row::<i32, _>("SELECT SUM(x) FROM foo", &[], |r| r.get(0))
|
||||||
|
.unwrap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,7 +454,8 @@ mod test {
|
|||||||
{
|
{
|
||||||
let tx = db.transaction().unwrap();
|
let tx = db.transaction().unwrap();
|
||||||
assert_eq!(6i32,
|
assert_eq!(6i32,
|
||||||
tx.query_row("SELECT SUM(x) FROM foo", &[], |r| r.get(0)).unwrap());
|
tx.query_row::<i32, _>("SELECT SUM(x) FROM foo", &[], |r| r.get(0))
|
||||||
|
.unwrap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -547,7 +549,7 @@ mod test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn assert_current_sum(x: i32, conn: &Connection) {
|
fn assert_current_sum(x: i32, conn: &Connection) {
|
||||||
let i = conn.query_row("SELECT SUM(x) FROM foo", &[], |r| r.get(0)).unwrap();
|
let i = conn.query_row::<i32, _>("SELECT SUM(x) FROM foo", &[], |r| r.get(0)).unwrap();
|
||||||
assert_eq!(x, i);
|
assert_eq!(x, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ mod test {
|
|||||||
db.execute("INSERT INTO foo(i) VALUES (?)", &[&Value::Integer(10)]).unwrap();
|
db.execute("INSERT INTO foo(i) VALUES (?)", &[&Value::Integer(10)]).unwrap();
|
||||||
|
|
||||||
assert_eq!(10i64,
|
assert_eq!(10i64,
|
||||||
db.query_row("SELECT i FROM foo", &[], |r| r.get(0)).unwrap());
|
db.query_row::<i64, _>("SELECT i FROM foo", &[], |r| r.get(0)).unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
Reference in New Issue
Block a user