Skip to content
This repository has been archived by the owner on Sep 12, 2018. It is now read-only.

Commit

Permalink
Post: Make tests pass on Rust 1.25.0
Browse files Browse the repository at this point in the history
For some reason, the converted doc test fails on Rust 1.25.0, while
working with other Rust versions. For simplicity, just convert it into
a regular test.
  • Loading branch information
Grisha Kruglov authored and grigoryk committed Aug 9, 2018
1 parent bf8c2c1 commit 5976869
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions core/src/sql_types.rs
Expand Up @@ -68,19 +68,6 @@ impl SQLValueType for ValueType {

/// Returns true if the provided integer is in the SQLite value space of this type. For
/// example, `1` is how we encode `true`.
///
/// ```
/// extern crate core_traits;
/// extern crate mentat_core;
/// use core_traits::ValueType;
/// use mentat_core::SQLValueType;
/// assert!(!ValueType::Instant.accommodates_integer(1493399581314));
/// assert!(!ValueType::Instant.accommodates_integer(1493399581314000));
/// assert!(ValueType::Boolean.accommodates_integer(1));
/// assert!(!ValueType::Boolean.accommodates_integer(-1));
/// assert!(!ValueType::Boolean.accommodates_integer(10));
/// assert!(!ValueType::String.accommodates_integer(10));
/// ```
fn accommodates_integer(&self, int: i64) -> bool {
use ValueType::*;
match *self {
Expand Down Expand Up @@ -140,3 +127,23 @@ impl SQLValueTypeSet for ValueTypeSet {
!acc.is_empty()
}
}

#[cfg(test)]
mod tests {
use core_traits::{
ValueType,
};
use sql_types::{
SQLValueType,
};

#[test]
fn test_accommodates_integer() {
assert!(!ValueType::Instant.accommodates_integer(1493399581314));
assert!(!ValueType::Instant.accommodates_integer(1493399581314000));
assert!(ValueType::Boolean.accommodates_integer(1));
assert!(!ValueType::Boolean.accommodates_integer(-1));
assert!(!ValueType::Boolean.accommodates_integer(10));
assert!(!ValueType::String.accommodates_integer(10));
}
}

0 comments on commit 5976869

Please sign in to comment.