~dkellner/chronofold

5a7e4d8dea103bc178ad4845a487472bfb1a4fd6 — Dominik Kellner 3 years ago 9fe1d3c
Add (failing) test for concurrent inserts referencing deletions
1 files changed, 14 insertions(+), 4 deletions(-)

M tests/corner_cases.rs
M tests/corner_cases.rs => tests/corner_cases.rs +14 -4
@@ 89,6 89,16 @@ fn concurrent_insertion_deletion() {
}

#[test]
fn concurrent_inserts_referencing_deletions() {
    let mutate = |s: &mut Session<u8, char>| {
        s.remove(LogIndex(2));
        let delete_idx = LogIndex(3);
        s.insert_after(delete_idx, '3');
    };
    assert_concurrent_eq("133", "12", mutate, mutate);
}

#[test]
fn insert_referencing_deleted_element() {
    let mut cfold = Chronofold::<u8, char>::default();
    let mut session = cfold.session(1);


@@ 128,13 138,13 @@ where
    assert_eq!(
        expected,
        format!("{}", cfold_left),
        "Left ops:\n{:#?}",
        cfold_left.iter_ops(..).collect::<Vec<Op<_, &char>>>(),
        "\n{}",
        cfold_left.formatted_log(),
    );
    assert_eq!(
        expected,
        format!("{}", cfold_right),
        "Right ops:\n{:#?}",
        cfold_right.iter_ops(..).collect::<Vec<Op<_, &char>>>()
        "\n{}",
        cfold_right.formatted_log(),
    );
}