Skip to content

Commit 6b20001

Browse files
committed
fix a-part
1 parent dc3cee6 commit 6b20001

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/intersections.rs

+9-12
Original file line numberDiff line numberDiff line change
@@ -314,17 +314,17 @@ impl Intersections {
314314
.base_interval
315315
.try_lock()
316316
.expect("failed to lock interval");
317-
if oi.start() < bi.start() || oi.stop() > bi.stop() {
318-
let mut oc = oi.clone_box();
317+
//if oi.start() < bi.start() || oi.stop() > bi.stop() {
318+
if oi.start() > bi.start() || oi.stop() < bi.stop() {
319+
let mut oc = bi.clone_box();
319320
oc.set_start(oi.start().max(bi.start()));
320321
oc.set_stop(oi.stop().min(bi.stop()));
321322
drop(bi);
322323
drop(oi);
323324
Arc::new(Mutex::new(oc))
324325
} else {
325-
drop(bi);
326326
drop(oi);
327-
o.interval.clone()
327+
Arc::new(Mutex::new(bi.clone_box()))
328328
}
329329
})
330330
.collect()
@@ -692,22 +692,18 @@ mod tests {
692692
ro.a_requirements = OverlapAmount::Bases(1);
693693
ro.b_requirements = OverlapAmount::Bases(1);
694694
let r = intersections.report(&ro);
695-
assert_eq!(r.len(), 2);
695+
assert_eq!(r.len(), 1);
696696
let rf = &r[0];
697697
// test that a is 1-10
698698
assert_eq!(rf.a.as_ref().unwrap().lock().start(), 1);
699699
assert_eq!(rf.a.as_ref().unwrap().lock().stop(), 10);
700700
// test that b is 3-6
701-
assert_eq!(rf.b.len(), 1);
701+
assert_eq!(rf.b.len(), 2);
702702
assert_eq!(rf.b[0].lock().start(), 3);
703703
assert_eq!(rf.b[0].lock().stop(), 6);
704704

705-
let rf = &r[1];
706-
assert_eq!(rf.a.as_ref().unwrap().lock().start(), 1);
707-
assert_eq!(rf.a.as_ref().unwrap().lock().stop(), 10);
708-
assert_eq!(rf.b.len(), 1);
709-
assert_eq!(rf.b[0].lock().start(), 8);
710-
assert_eq!(rf.b[0].lock().stop(), 12);
705+
assert_eq!(rf.b[1].lock().start(), 8);
706+
assert_eq!(rf.b[1].lock().stop(), 12);
711707
}
712708

713709
#[test]
@@ -721,6 +717,7 @@ mod tests {
721717
ro.a_requirements = OverlapAmount::Bases(1);
722718
ro.b_requirements = OverlapAmount::Bases(1);
723719
let r = intersections.report(&ro);
720+
eprintln!("r: {:?}", r);
724721
// a: 3-6, b: 3-6
725722
// a: 8-10, b: 8-10
726723
eprintln!("{:?}", r);

0 commit comments

Comments
 (0)