mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 00:39:20 +08:00
Address additional clippy warnings
This commit is contained in:
parent
2bd54578f5
commit
41fe698cec
@ -140,6 +140,7 @@ impl error::Error for Error {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(match_same_arms)]
|
||||
fn cause(&self) -> Option<&error::Error> {
|
||||
match *self {
|
||||
Error::SqliteFailure(ref err, _) => Some(err),
|
||||
@ -159,6 +160,7 @@ impl error::Error for Error {
|
||||
|
||||
#[cfg(feature = "functions")]
|
||||
Error::InvalidFunctionParameterType => None,
|
||||
|
||||
#[cfg(feature = "functions")]
|
||||
Error::UserFunctionError(ref err) => Some(&**err),
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ impl<'a> Context<'a> {
|
||||
ffi::sqlite3_set_auxdata(self.ctx,
|
||||
arg,
|
||||
mem::transmute(boxed),
|
||||
Some(mem::transmute(free_boxed_value::<T>)))
|
||||
Some(free_boxed_value::<T>))
|
||||
};
|
||||
}
|
||||
|
||||
@ -480,7 +480,7 @@ impl InnerConnection {
|
||||
Some(call_boxed_closure::<F, T>),
|
||||
None,
|
||||
None,
|
||||
Some(mem::transmute(free_boxed_value::<F>)))
|
||||
Some(free_boxed_value::<F>))
|
||||
};
|
||||
self.decode_result(r)
|
||||
}
|
||||
@ -597,7 +597,7 @@ impl InnerConnection {
|
||||
None,
|
||||
Some(call_boxed_step::<A, D, T>),
|
||||
Some(call_boxed_final::<A, D, T>),
|
||||
Some(mem::transmute(free_boxed_value::<D>)))
|
||||
Some(free_boxed_value::<D>))
|
||||
};
|
||||
self.decode_result(r)
|
||||
}
|
||||
@ -626,6 +626,7 @@ mod test {
|
||||
use std::collections::HashMap;
|
||||
use libc::c_double;
|
||||
use self::regex::Regex;
|
||||
use std::f64::EPSILON;
|
||||
|
||||
use {Connection, Error, Result};
|
||||
use functions::{Aggregate, Context};
|
||||
@ -642,7 +643,7 @@ mod test {
|
||||
db.create_scalar_function("half", 1, true, half).unwrap();
|
||||
let result: Result<f64> = db.query_row("SELECT half(6)", &[], |r| r.get(0));
|
||||
|
||||
assert_eq!(3f64, result.unwrap());
|
||||
assert!((3f64 - result.unwrap()).abs() < EPSILON);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -650,7 +651,7 @@ mod test {
|
||||
let db = Connection::open_in_memory().unwrap();
|
||||
db.create_scalar_function("half", 1, true, half).unwrap();
|
||||
let result: Result<f64> = db.query_row("SELECT half(6)", &[], |r| r.get(0));
|
||||
assert_eq!(3f64, result.unwrap());
|
||||
assert!((3f64 - result.unwrap()).abs() < EPSILON);
|
||||
|
||||
db.remove_function("half", 1).unwrap();
|
||||
let result: Result<f64> = db.query_row("SELECT half(6)", &[], |r| r.get(0));
|
||||
|
10
src/lib.rs
10
src/lib.rs
@ -53,9 +53,6 @@
|
||||
#![cfg_attr(feature="clippy", feature(plugin))]
|
||||
#![cfg_attr(feature="clippy", plugin(clippy))]
|
||||
|
||||
// Clippy complains about SQLite in our doc comments, but they're fine.
|
||||
#![cfg_attr(feature="clippy", allow(doc_markdown))]
|
||||
|
||||
extern crate libc;
|
||||
extern crate libsqlite3_sys as ffi;
|
||||
#[macro_use]
|
||||
@ -1224,10 +1221,9 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_open_with_flags() {
|
||||
for bad_flags in [OpenFlags::empty(),
|
||||
SQLITE_OPEN_READ_ONLY | SQLITE_OPEN_READ_WRITE,
|
||||
SQLITE_OPEN_READ_ONLY | SQLITE_OPEN_CREATE]
|
||||
.iter() {
|
||||
for bad_flags in &[OpenFlags::empty(),
|
||||
SQLITE_OPEN_READ_ONLY | SQLITE_OPEN_READ_WRITE,
|
||||
SQLITE_OPEN_READ_ONLY | SQLITE_OPEN_CREATE] {
|
||||
assert!(Connection::open_in_memory_with_flags(*bad_flags).is_err());
|
||||
}
|
||||
}
|
||||
|
@ -174,6 +174,7 @@ impl<'conn> Drop for Transaction<'conn> {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[cfg_attr(feature="clippy", allow(similar_names))]
|
||||
mod test {
|
||||
use Connection;
|
||||
|
||||
|
10
src/types.rs
10
src/types.rs
@ -328,11 +328,13 @@ impl FromSql for Value {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[cfg_attr(feature="clippy", allow(similar_names))]
|
||||
mod test {
|
||||
use Connection;
|
||||
use super::time;
|
||||
use Error;
|
||||
use libc::{c_int, c_double};
|
||||
use std::f64::EPSILON;
|
||||
|
||||
fn checked_memory_handle() -> Connection {
|
||||
let db = Connection::open_in_memory().unwrap();
|
||||
@ -403,6 +405,7 @@ mod test {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(feature="clippy", allow(cyclomatic_complexity))]
|
||||
fn test_mismatched_types() {
|
||||
fn is_invalid_column_type(err: Error) -> bool {
|
||||
match err {
|
||||
@ -426,7 +429,7 @@ mod test {
|
||||
assert_eq!(vec![1, 2], row.get_checked::<i32, Vec<u8>>(0).unwrap());
|
||||
assert_eq!("text", row.get_checked::<i32, String>(1).unwrap());
|
||||
assert_eq!(1, row.get_checked::<i32, c_int>(2).unwrap());
|
||||
assert_eq!(1.5, row.get_checked::<i32, c_double>(3).unwrap());
|
||||
assert!((1.5 - row.get_checked::<i32, c_double>(3).unwrap()).abs() < EPSILON);
|
||||
assert!(row.get_checked::<i32, Option<c_int>>(4).unwrap().is_none());
|
||||
assert!(row.get_checked::<i32, Option<c_double>>(4).unwrap().is_none());
|
||||
assert!(row.get_checked::<i32, Option<String>>(4).unwrap().is_none());
|
||||
@ -491,7 +494,10 @@ mod test {
|
||||
assert_eq!(Value::Text(String::from("text")),
|
||||
row.get_checked::<i32, Value>(1).unwrap());
|
||||
assert_eq!(Value::Integer(1), row.get_checked::<i32, Value>(2).unwrap());
|
||||
assert_eq!(Value::Real(1.5), row.get_checked::<i32, Value>(3).unwrap());
|
||||
match row.get_checked::<i32, Value>(3).unwrap() {
|
||||
Value::Real(val) => assert!((1.5 - val).abs() < EPSILON),
|
||||
x => panic!("Invalid Value {:?}", x),
|
||||
}
|
||||
assert_eq!(Value::Null, row.get_checked::<i32, Value>(4).unwrap());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user