fix: yata fuzzing now works

This commit is contained in:
Zixuan Chen 2022-10-09 11:45:58 +08:00
parent 5ca3a42a0b
commit b11fe7394e
4 changed files with 11 additions and 2 deletions

View file

@ -77,6 +77,11 @@ impl Tracker {
} }
} }
/// check whether id_to_cursor correctly reflect the status of the content
fn check_consistency(&self) {
todo!()
}
fn turn_on(&mut self, _id: IdSpan) {} fn turn_on(&mut self, _id: IdSpan) {}
fn turn_off(&mut self, _id: IdSpan) {} fn turn_off(&mut self, _id: IdSpan) {}
fn checkout(&mut self, _vv: VersionVector) {} fn checkout(&mut self, _vv: VersionVector) {}

View file

@ -62,6 +62,7 @@ pub enum StatusChange {
pub(super) type YSpanTreeTrait = CumulateTreeTrait<YSpan, 10>; pub(super) type YSpanTreeTrait = CumulateTreeTrait<YSpan, 10>;
impl YSpan { impl YSpan {
/// this is the last id of the span, which is **included** by self
#[inline] #[inline]
pub fn last_id(&self) -> ID { pub fn last_id(&self) -> ID {
self.id.inc(self.len as i32 - 1) self.id.inc(self.len as i32 - 1)
@ -77,7 +78,7 @@ impl YSpan {
pub fn contain_id(&self, id: ID) -> bool { pub fn contain_id(&self, id: ID) -> bool {
self.id.client_id == id.client_id self.id.client_id == id.client_id
&& self.id.counter <= id.counter && self.id.counter <= id.counter
&& self.last_id().counter > id.counter && self.last_id().counter >= id.counter
} }
} }

View file

@ -5,7 +5,7 @@ use crate::{Rle, RleTreeTrait};
use super::{node::LeafNode, tree_trait::Position}; use super::{node::LeafNode, tree_trait::Position};
/// when len > 0, it acts as a selection. When iterating the tree, the len should be the size of the element. /// when len > 0, it acts as a selection. When iterating the tree, the len should be the size of the element.
#[derive(PartialEq, Eq)] #[derive(PartialEq, Eq, Debug)]
pub struct UnsafeCursor<'tree, 'bump, T: Rle, A: RleTreeTrait<T>> { pub struct UnsafeCursor<'tree, 'bump, T: Rle, A: RleTreeTrait<T>> {
pub leaf: NonNull<LeafNode<'bump, T, A>>, pub leaf: NonNull<LeafNode<'bump, T, A>>,
pub index: usize, pub index: usize,
@ -32,11 +32,13 @@ impl<'tree, 'bump, T: Rle, A: RleTreeTrait<T>> Clone for UnsafeCursor<'tree, 'bu
impl<'tree, 'bump: 'tree, T: Rle, A: RleTreeTrait<T>> Copy for UnsafeCursor<'tree, 'bump, T, A> {} impl<'tree, 'bump: 'tree, T: Rle, A: RleTreeTrait<T>> Copy for UnsafeCursor<'tree, 'bump, T, A> {}
#[repr(transparent)] #[repr(transparent)]
#[derive(Debug)]
pub struct SafeCursor<'tree, 'bump, T: Rle, A: RleTreeTrait<T>>( pub struct SafeCursor<'tree, 'bump, T: Rle, A: RleTreeTrait<T>>(
pub(crate) UnsafeCursor<'tree, 'bump, T, A>, pub(crate) UnsafeCursor<'tree, 'bump, T, A>,
); );
#[repr(transparent)] #[repr(transparent)]
#[derive(Debug)]
pub struct SafeCursorMut<'tree, 'bump, T: Rle, A: RleTreeTrait<T>>( pub struct SafeCursorMut<'tree, 'bump, T: Rle, A: RleTreeTrait<T>>(
pub(crate) UnsafeCursor<'tree, 'bump, T, A>, pub(crate) UnsafeCursor<'tree, 'bump, T, A>,
); );

View file

@ -137,6 +137,7 @@ impl<'tree, 'bump: 'tree, T: Rle, A: RleTreeTrait<T>> Iterator for Iter<'tree, '
end.offset - cursor.offset, end.offset - cursor.offset,
) )
}); });
cursor.offset = end.offset;
self.cursor = None; self.cursor = None;
return ans; return ans;
} }