1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! # Boolean Type
//! This module contains the boolean type.
pub type TBool = crate::RedisGeneric<bool>;

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_bool() {
        let client = redis::Client::open("redis://localhost/").unwrap();
        let mut b1 = TBool::with_value(true, "b1", client.clone());
        let mut b2 = TBool::with_value(false, "b2", client.clone());
        let b3 = TBool::with_value(true, "b3", client.clone());
        let b4 = TBool::with_value(false, "b4", client.clone());
        assert!(b1.cache.unwrap());
        assert_eq!(b2.cache.unwrap(), false);
        b1.store(false);
        assert!(!(b1.cache.unwrap()));
        b1 = b1 & b3;
        assert!(!(b1.cache.unwrap()));
        b2 = b2 | b4;
        assert_eq!(b2.cache.unwrap(), false);
        b1 = b1 ^ b2;
        assert!(!(b1.cache.unwrap()));
    }

    #[test]
    fn test_equalsign() {
        let client = redis::Client::open("redis://localhost/").unwrap();
        let mut b1 = TBool::with_value(true, "b1", client.clone());
        let b2 = TBool::with_value(false, "b2", client.clone());
        b1.store(false);
        assert!(!b1.cache.unwrap());
        assert!(!b2.cached().unwrap());
    }

    #[test]
    fn test_partialeq() {
        let client = redis::Client::open("redis://localhost/").unwrap();
        let b1 = TBool::with_value(true, "b5", client.clone());
        assert_eq!(b1, true);
        assert_ne!(b1, false);
    }
}