Fix clippy warnings

This commit is contained in:
gwenn 2019-02-02 11:37:26 +01:00
parent f695f185c2
commit 8862b17340
10 changed files with 18 additions and 18 deletions

View File

@ -1247,11 +1247,9 @@ mod test {
let tx2 = db2.transaction().unwrap(); let tx2 = db2.transaction().unwrap();
// SELECT first makes sqlite lock with a shared lock // SELECT first makes sqlite lock with a shared lock
let _ = tx1 tx1.query_row("SELECT x FROM foo LIMIT 1", NO_PARAMS, |_| ())
.query_row("SELECT x FROM foo LIMIT 1", NO_PARAMS, |_| ())
.unwrap(); .unwrap();
let _ = tx2 tx2.query_row("SELECT x FROM foo LIMIT 1", NO_PARAMS, |_| ())
.query_row("SELECT x FROM foo LIMIT 1", NO_PARAMS, |_| ())
.unwrap(); .unwrap();
tx1.execute("INSERT INTO foo VALUES(?1)", &[1]).unwrap(); tx1.execute("INSERT INTO foo VALUES(?1)", &[1]).unwrap();

View File

@ -57,13 +57,13 @@ mod test {
assert_eq!(99, db.limit(Limit::SQLITE_LIMIT_VARIABLE_NUMBER)); assert_eq!(99, db.limit(Limit::SQLITE_LIMIT_VARIABLE_NUMBER));
// SQLITE_LIMIT_TRIGGER_DEPTH was added in SQLite 3.6.18. // SQLITE_LIMIT_TRIGGER_DEPTH was added in SQLite 3.6.18.
if crate::version_number() >= 3006018 { if crate::version_number() >= 3_006_018 {
db.set_limit(Limit::SQLITE_LIMIT_TRIGGER_DEPTH, 32); db.set_limit(Limit::SQLITE_LIMIT_TRIGGER_DEPTH, 32);
assert_eq!(32, db.limit(Limit::SQLITE_LIMIT_TRIGGER_DEPTH)); assert_eq!(32, db.limit(Limit::SQLITE_LIMIT_TRIGGER_DEPTH));
} }
// SQLITE_LIMIT_WORKER_THREADS was added in SQLite 3.8.7. // SQLITE_LIMIT_WORKER_THREADS was added in SQLite 3.8.7.
if crate::version_number() >= 3008007 { if crate::version_number() >= 3_008_007 {
db.set_limit(Limit::SQLITE_LIMIT_WORKER_THREADS, 2); db.set_limit(Limit::SQLITE_LIMIT_WORKER_THREADS, 2);
assert_eq!(2, db.limit(Limit::SQLITE_LIMIT_WORKER_THREADS)); assert_eq!(2, db.limit(Limit::SQLITE_LIMIT_WORKER_THREADS));
} }

View File

@ -854,6 +854,7 @@ mod test {
assert_eq!(1, doubled_id); assert_eq!(1, doubled_id);
// second row should be Err // second row should be Err
#[allow(clippy::match_wild_err_arm)]
match rows.next().unwrap() { match rows.next().unwrap() {
Ok(_) => panic!("invalid Ok"), Ok(_) => panic!("invalid Ok"),
Err(Error::SqliteSingleThreadedMode) => (), Err(Error::SqliteSingleThreadedMode) => (),
@ -1038,7 +1039,7 @@ mod test {
use std::collections::BTreeSet; use std::collections::BTreeSet;
let data: BTreeSet<String> = ["one", "two", "three"] let data: BTreeSet<String> = ["one", "two", "three"]
.into_iter() .iter()
.map(|s| s.to_string()) .map(|s| s.to_string())
.collect(); .collect();
db.query_row("SELECT ?1, ?2, ?3", &data, |row| row.get::<_, String>(0)) db.query_row("SELECT ?1, ?2, ?3", &data, |row| row.get::<_, String>(0))

View File

@ -232,11 +232,11 @@ mod test {
check_ranges::<i16>(&db, &[-32769, 32768], &[-32768, -1, 0, 1, 32767]); check_ranges::<i16>(&db, &[-32769, 32768], &[-32768, -1, 0, 1, 32767]);
check_ranges::<i32>( check_ranges::<i32>(
&db, &db,
&[-2147483649, 2147483648], &[-2_147_483_649, 2_147_483_648],
&[-2147483648, -1, 0, 1, 2147483647], &[-2_147_483_648, -1, 0, 1, 2_147_483_647],
); );
check_ranges::<u8>(&db, &[-2, -1, 256], &[0, 1, 255]); check_ranges::<u8>(&db, &[-2, -1, 256], &[0, 1, 255]);
check_ranges::<u16>(&db, &[-2, -1, 65536], &[0, 1, 65535]); check_ranges::<u16>(&db, &[-2, -1, 65536], &[0, 1, 65535]);
check_ranges::<u32>(&db, &[-2, -1, 4294967296], &[0, 1, 4294967295]); check_ranges::<u32>(&db, &[-2, -1, 4_294_967_296], &[0, 1, 4_294_967_295]);
} }
} }

View File

@ -223,6 +223,7 @@ mod test {
} }
#[test] #[test]
#[allow(clippy::cyclomatic_complexity)]
fn test_mismatched_types() { fn test_mismatched_types() {
fn is_invalid_column_type(err: Error) -> bool { fn is_invalid_column_type(err: Error) -> bool {
match err { match err {

View File

@ -54,10 +54,10 @@ mod test {
ts_vec.push(time::Timespec::new(10_000, 0)); //January 1, 1970 2:46:40 AM ts_vec.push(time::Timespec::new(10_000, 0)); //January 1, 1970 2:46:40 AM
ts_vec.push(time::Timespec::new(10_000, 1000)); //January 1, 1970 2:46:40 AM (and one microsecond) ts_vec.push(time::Timespec::new(10_000, 1000)); //January 1, 1970 2:46:40 AM (and one microsecond)
ts_vec.push(time::Timespec::new(1500391124, 1_000_000)); //July 18, 2017 ts_vec.push(time::Timespec::new(1_500_391_124, 1_000_000)); //July 18, 2017
ts_vec.push(time::Timespec::new(2000000000, 2_000_000)); //May 18, 2033 ts_vec.push(time::Timespec::new(2_000_000_000, 2_000_000)); //May 18, 2033
ts_vec.push(time::Timespec::new(3000000000, 999_999_999)); //January 24, 2065 ts_vec.push(time::Timespec::new(3_000_000_000, 999_999_999)); //January 24, 2065
ts_vec.push(time::Timespec::new(10000000000, 0)); //November 20, 2286 ts_vec.push(time::Timespec::new(10_000_000_000, 0)); //November 20, 2286
for ts in ts_vec { for ts in ts_vec {
db.execute("INSERT INTO foo(t) VALUES (?)", &[&ts]).unwrap(); db.execute("INSERT INTO foo(t) VALUES (?)", &[&ts]).unwrap();

View File

@ -180,7 +180,7 @@ mod test {
array::load_module(&db).unwrap(); array::load_module(&db).unwrap();
let v = vec![1i64, 2, 3, 4]; let v = vec![1i64, 2, 3, 4];
let values = v.into_iter().map(|i| Value::from(i)).collect(); let values = v.into_iter().map(Value::from).collect();
let ptr = Rc::new(values); let ptr = Rc::new(values);
{ {
let mut stmt = db.prepare("SELECT value from rarray(?);").unwrap(); let mut stmt = db.prepare("SELECT value from rarray(?);").unwrap();

View File

@ -366,7 +366,7 @@ mod test {
.query_map(NO_PARAMS, |row| row.get::<_, i32>(0)) .query_map(NO_PARAMS, |row| row.get::<_, i32>(0))
.unwrap() .unwrap()
.collect(); .collect();
let sum = ids.unwrap().iter().fold(0, |acc, &id| acc + id); let sum = ids.unwrap().iter().sum::<i32>();
assert_eq!(sum, 15); assert_eq!(sum, 15);
} }
db.execute_batch("DROP TABLE vtab").unwrap(); db.execute_batch("DROP TABLE vtab").unwrap();

View File

@ -270,7 +270,7 @@ mod test {
#[test] #[test]
fn test_series_module() { fn test_series_module() {
let version = unsafe { ffi::sqlite3_libversion_number() }; let version = unsafe { ffi::sqlite3_libversion_number() };
if version < 3008012 { if version < 3_008_012 {
return; return;
} }

View File

@ -88,7 +88,7 @@ fn test_dummy_module() {
.unwrap(); .unwrap();
let version = version_number(); let version = version_number();
if version < 3008012 { if version < 3_008_012 {
return; return;
} }