reifydb_value/value/boolean/
compare.rs1#[inline]
5pub fn is_equal(l: bool, r: bool) -> bool {
6 l == r
7}
8
9#[inline]
10pub fn is_not_equal(l: bool, r: bool) -> bool {
11 l != r
12}
13
14#[inline]
15pub fn is_greater_than(l: bool, r: bool) -> bool {
16 l & !r
17}
18
19#[inline]
20pub fn is_greater_than_equal(l: bool, r: bool) -> bool {
21 l >= r
22}
23
24#[inline]
25pub fn is_less_than(l: bool, r: bool) -> bool {
26 !l & r
27}
28
29#[inline]
30pub fn is_less_than_equal(l: bool, r: bool) -> bool {
31 l <= r
32}
33
34#[cfg(test)]
35pub mod tests {
36 use super::*;
37
38 #[test]
39 fn test_is_equal() {
40 assert!(is_equal(true, true));
41 assert!(is_equal(false, false));
42 assert!(!is_equal(true, false));
43 assert!(!is_equal(false, true));
44 }
45
46 #[test]
47 fn test_is_not_equal() {
48 assert!(!is_not_equal(true, true));
49 assert!(!is_not_equal(false, false));
50 assert!(is_not_equal(true, false));
51 assert!(is_not_equal(false, true));
52 }
53
54 #[test]
55 fn test_is_greater_than() {
56 assert!(is_greater_than(true, false));
57 assert!(!is_greater_than(false, true));
58 assert!(!is_greater_than(true, true));
59 assert!(!is_greater_than(false, false));
60 }
61
62 #[test]
63 fn test_is_greater_than_equal() {
64 assert!(is_greater_than_equal(true, false));
65 assert!(!is_greater_than_equal(false, true));
66 assert!(is_greater_than_equal(true, true));
67 assert!(is_greater_than_equal(false, false));
68 }
69
70 #[test]
71 fn test_is_less_than() {
72 assert!(!is_less_than(true, false));
73 assert!(is_less_than(false, true));
74 assert!(!is_less_than(true, true));
75 assert!(!is_less_than(false, false));
76 }
77
78 #[test]
79 fn test_is_less_than_equal() {
80 assert!(!is_less_than_equal(true, false));
81 assert!(is_less_than_equal(false, true));
82 assert!(is_less_than_equal(true, true));
83 assert!(is_less_than_equal(false, false));
84 }
85}