dtypes/redis/
bool_type.rs1pub type TBool = crate::redis::types::Generic<bool>;
4
5#[cfg(test)]
6mod tests {
7 use super::*;
8
9 #[test]
10 fn test_bool() {
11 let client = redis::Client::open("redis://localhost/").unwrap();
12 let mut b1 = TBool::with_value(true, "b1", client.clone());
13 let mut b2 = TBool::with_value(false, "b2", client.clone());
14 let b3 = TBool::with_value(true, "b3", client.clone());
15 let b4 = TBool::with_value(false, "b4", client.clone());
16 assert!(b1.cache.unwrap());
17 assert_eq!(b2.cache.unwrap(), false);
18 b1.store(false);
19 assert!(!(b1.cache.unwrap()));
20 b1 = b1 & b3;
21 assert!(!(b1.cache.unwrap()));
22 b2 = b2 | b4;
23 assert_eq!(b2.cache.unwrap(), false);
24 b1 = b1 ^ b2;
25 assert!(!(b1.cache.unwrap()));
26 }
27
28 #[test]
29 fn test_equalsign() {
30 let client = redis::Client::open("redis://localhost/").unwrap();
31 let mut b1 = TBool::with_value(true, "b1", client.clone());
32 let b2 = TBool::with_value(false, "b2", client.clone());
33 b1.store(false);
34 assert!(!b1.cache.unwrap());
35 assert!(!b2.cached().unwrap());
36 }
37
38 #[test]
39 fn test_partialeq() {
40 let client = redis::Client::open("redis://localhost/").unwrap();
41 let b1 = TBool::with_value(true, "b5", client.clone());
42 assert_eq!(b1, true);
43 assert_ne!(b1, false);
44 }
45}