mirror of
https://github.com/isar/rusqlite.git
synced 2025-01-20 07:10:51 +08:00
Cargo format
This commit is contained in:
parent
ebcec59969
commit
f264873999
@ -1,7 +1,7 @@
|
|||||||
use super::{Value, ValueRef};
|
use super::{Value, ValueRef};
|
||||||
|
use std::convert::TryInto;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::convert::TryInto;
|
|
||||||
|
|
||||||
/// Enum listing possible errors from `FromSql` trait.
|
/// Enum listing possible errors from `FromSql` trait.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -132,7 +132,7 @@ impl fmt::Display for Type {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::Value;
|
use super::Value;
|
||||||
use crate::{Connection, Error, NO_PARAMS, params, Statement};
|
use crate::{params, Connection, Error, Statement, NO_PARAMS};
|
||||||
use std::f64::EPSILON;
|
use std::f64::EPSILON;
|
||||||
use std::os::raw::{c_double, c_int};
|
use std::os::raw::{c_double, c_int};
|
||||||
|
|
||||||
@ -388,18 +388,24 @@ mod test {
|
|||||||
|
|
||||||
macro_rules! test_conversion {
|
macro_rules! test_conversion {
|
||||||
($db_etc:ident, $insert_value:expr, $get_type:ty, expect $expected_value:expr) => {
|
($db_etc:ident, $insert_value:expr, $get_type:ty, expect $expected_value:expr) => {
|
||||||
$db_etc.insert_statement.execute(params![$insert_value]).unwrap();
|
$db_etc
|
||||||
let res = $db_etc.query_statement.query_row(NO_PARAMS, |row| {
|
.insert_statement
|
||||||
row.get::<_, $get_type>(0)
|
.execute(params![$insert_value])
|
||||||
});
|
.unwrap();
|
||||||
|
let res = $db_etc
|
||||||
|
.query_statement
|
||||||
|
.query_row(NO_PARAMS, |row| row.get::<_, $get_type>(0));
|
||||||
assert_eq!(res.unwrap(), $expected_value);
|
assert_eq!(res.unwrap(), $expected_value);
|
||||||
$db_etc.delete_statement.execute(NO_PARAMS).unwrap();
|
$db_etc.delete_statement.execute(NO_PARAMS).unwrap();
|
||||||
};
|
};
|
||||||
($db_etc:ident, $insert_value:expr, $get_type:ty, expect_error) => {
|
($db_etc:ident, $insert_value:expr, $get_type:ty, expect_error) => {
|
||||||
$db_etc.insert_statement.execute(params![$insert_value]).unwrap();
|
$db_etc
|
||||||
let res = $db_etc.query_statement.query_row(NO_PARAMS, |row| {
|
.insert_statement
|
||||||
row.get::<_, $get_type>(0)
|
.execute(params![$insert_value])
|
||||||
});
|
.unwrap();
|
||||||
|
let res = $db_etc
|
||||||
|
.query_statement
|
||||||
|
.query_row(NO_PARAMS, |row| row.get::<_, $get_type>(0));
|
||||||
res.unwrap_err();
|
res.unwrap_err();
|
||||||
$db_etc.delete_statement.execute(NO_PARAMS).unwrap();
|
$db_etc.delete_statement.execute(NO_PARAMS).unwrap();
|
||||||
};
|
};
|
||||||
@ -455,6 +461,5 @@ mod test {
|
|||||||
// Float to int conversion, never works even if the actual value is an
|
// Float to int conversion, never works even if the actual value is an
|
||||||
// integer.
|
// integer.
|
||||||
test_conversion!(db_etc, 0f64, i64, expect_error);
|
test_conversion!(db_etc, 0f64, i64, expect_error);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user