This commit is contained in:
Austen Adler 2022-07-15 18:58:33 -04:00
parent d69cec4d73
commit b2d6e18c82

View File

@ -58,11 +58,13 @@ impl SelectionDesc {
left: self.left, left: self.left,
right: self.left, right: self.left,
}); });
// My right is contained in b // My right is contained in b
let right_contained = b.contains(&SelectionDesc { let right_contained = b.contains(&SelectionDesc {
left: self.right, left: self.right,
right: self.right, right: self.right,
}); });
// b is contaned in self // b is contaned in self
let b_contained = self.contains(b); let b_contained = self.contains(b);
@ -527,7 +529,7 @@ mod test {
// Selection desc creator // Selection desc creator
macro_rules! sd { macro_rules! sd {
($b:expr, $d:expr) => {{ ($b:expr, $d:expr) => {{
sd!(1,$b,1,$d) sd!(1, $b, 1, $d)
}}; }};
($a:expr, $b:expr,$c:expr,$d:expr) => {{ ($a:expr, $b:expr,$c:expr,$d:expr) => {{
SelectionDesc { SelectionDesc {
@ -543,40 +545,37 @@ mod test {
#[test] #[test]
fn test_anchor_position() { fn test_anchor_position() {
// Check parsing // Check parsing
assert_eq!(sd!(18,9,10,1), SD); assert_eq!(sd!(18, 9, 10, 1), SD);
// Check if multiple parsed ones match // Check if multiple parsed ones match
assert_eq!( assert_eq!(sd!(18, 9, 10, 1), sd!(18, 9, 10, 1));
sd!(18,9,10,1),
sd!(18,9,10,1)
);
} }
#[test] #[test]
fn test_sort() { fn test_sort() {
// Check if sorting works // Check if sorting works
assert_eq!(SD.sort(), sd!(10,1,18,9)); assert_eq!(SD.sort(), sd!(10, 1, 18, 9));
assert_eq!(SD.sort(), SD.sort().sort()); assert_eq!(SD.sort(), SD.sort().sort());
} }
#[test] #[test]
fn test_contains() { fn test_contains() {
assert!(SD.contains(&SD)); assert!(SD.contains(&SD));
assert!(SD.contains(&sd!(17,9,10,1))); assert!(SD.contains(&sd!(17, 9, 10, 1)));
assert!(SD.contains(&sd!(18,8,10,1))); assert!(SD.contains(&sd!(18, 8, 10, 1)));
assert!(SD.contains(&sd!(18,9,11,1))); assert!(SD.contains(&sd!(18, 9, 11, 1)));
assert!(SD.contains(&sd!(18,9,10,2))); assert!(SD.contains(&sd!(18, 9, 10, 2)));
assert!(SD.contains(&sd!(10,1,17,9))); assert!(SD.contains(&sd!(10, 1, 17, 9)));
assert!(SD.contains(&sd!(10,1,18,8))); assert!(SD.contains(&sd!(10, 1, 18, 8)));
assert!(SD.contains(&sd!(11,1,18,9))); assert!(SD.contains(&sd!(11, 1, 18, 9)));
assert!(SD.contains(&sd!(10,2,18,9))); assert!(SD.contains(&sd!(10, 2, 18, 9)));
assert!(!SD.contains(&sd!(19,9,10,1))); assert!(!SD.contains(&sd!(19, 9, 10, 1)));
assert!(!SD.contains(&sd!(18,10,10,1))); assert!(!SD.contains(&sd!(18, 10, 10, 1)));
assert!(!SD.contains(&sd!(18,9,9,1))); assert!(!SD.contains(&sd!(18, 9, 9, 1)));
assert!(!SD.contains(&sd!(18,9,10,0))); assert!(!SD.contains(&sd!(18, 9, 10, 0)));
assert!(!SD.contains(&sd!(10,1,19,9))); assert!(!SD.contains(&sd!(10, 1, 19, 9)));
assert!(!SD.contains(&sd!(10,1,18,10))); assert!(!SD.contains(&sd!(10, 1, 18, 10)));
assert!(!SD.contains(&sd!(9,1,18,9))); assert!(!SD.contains(&sd!(9, 1, 18, 9)));
assert!(!SD.contains(&sd!(10,0,18,9))); assert!(!SD.contains(&sd!(10, 0, 18, 9)));
} }
#[test] #[test]