Expose version(), version_number(), and source_id() functions.

This commit is contained in:
John Gallagher
2017-02-06 20:19:55 -05:00
parent e971f63553
commit eb099952ac
3 changed files with 40 additions and 2 deletions

View File

@@ -89,12 +89,14 @@ pub use error::Error;
pub use ffi::ErrorCode;
pub use cache::CachedStatement;
pub use version::*;
#[cfg(feature = "load_extension")]
#[allow(deprecated)]
pub use load_extension_guard::{SqliteLoadExtensionGuard, LoadExtensionGuard};
pub mod types;
mod version;
mod transaction;
mod cache;
mod named_params;
@@ -1511,8 +1513,7 @@ mod test {
// extended error codes for constraints were added in SQLite 3.7.16; if we're
// running on a version at least that new, check for the extended code
let version = unsafe { ffi::sqlite3_libversion_number() };
if version >= 3007016 {
if version_number() >= 3007016 {
assert_eq!(err.extended_code, ffi::SQLITE_CONSTRAINT_NOTNULL)
}
}
@@ -1520,6 +1521,16 @@ mod test {
}
}
#[test]
fn test_version_string() {
let n = version_number();
let major = n / 1_000_000;
let minor = (n % 1_000_000) / 1_000;
let patch = n % 1_000;
assert_eq!(version(), format!("{}.{}.{}", major, minor, patch));
}
mod query_and_then_tests {
extern crate libsqlite3_sys as ffi;
use super::*;