fn level_2_undo() {
        // The original snapshot of the tree

        let start_tree = json!([null, {"key": true}, false]);

        let expected_tree = json!([null, {}, false]);

        // Create and initialise Dag to test
        let arena: Arena<Json> = Arena::new();
        let root = add_value_to_arena(start_tree.clone(), &arena);
        let start_cursor_location = Path::from_vec(vec![1, 0]);
        let expected_cursor_location = Path::from_vec(vec![1]);
        let mut dag = Dag::new(&arena, root, start_cursor_location.clone());

        // Step 1: Delete TestJson::object's child
        println!("Delete `key-value` pair");
        assert_eq!(
            Ok(EditSuccess::Delete {
                name: "field".to_string()
            }),
            dag.delete_cursor(1),
            "Not equal in action result."
        );
        assert_eq!(*dag.root(), expected_tree, "Not equal in tree.");
        assert_eq!(
            expected_cursor_location, dag.current_cursor_path,
            "Not equal in cursor location."
        );

        // Perform one undo.
        println!("Performing undo");
        assert_eq!(
            Ok(EditSuccess::Undo),
            dag.undo(1),
            "Not equal in action result"
        );
        assert_eq!(*dag.root(), start_tree, "Not equal in tree.");
        assert_eq!(
            start_cursor_location, dag.current_cursor_path,
            "Not equal in cursor location."
        );
    }
// This is the test cases for issue 27
This is the test cases for issue 27
This is the test cases for issue 27
fn level_2_undo() {
        // The original snapshot of the tree
        let start_tree = json!([null, {"key": true}, false]);
        let expected_tree = json!([null, {}, false]);
        // Create and initialise Dag to test
        let arena: Arena<Json> = Arena::new();
        let root = add_value_to_arena(start_tree.clone(), &arena);
        let start_cursor_location = Path::from_vec(vec![1, 0]);
        let expected_cursor_location = Path::from_vec(vec![1]);
        let mut dag = Dag::new(&arena, root, start_cursor_location.clone());
        // Step 1: Delete TestJson::object's child
        println!("Delete `key-value` pair");
        assert_eq!(
            Ok(EditSuccess::Delete {
                name: "field".to_string()
            }),
            dag.delete_cursor(1),
            "Not equal in action result."
        );
        assert_eq!(*dag.root(), expected_tree, "Not equal in tree.");
        assert_eq!(
            expected_cursor_location, dag.current_cursor_path,
            "Not equal in cursor location."
        );
        // Perform one undo.
        println!("Performing undo");
        assert_eq!(
            Ok(EditSuccess::Undo),
            dag.undo(1),
            "Not equal in action result"
        );
        assert_eq!(*dag.root(), start_tree, "Not equal in tree.");
        assert_eq!(
            start_cursor_location, dag.current_cursor_path,
            "Not equal in cursor location."
        );
    }
fn level_2_undo ( ) { // The original snapshot of the tree let start_tree = json ! ( [ null { " " true } false ] ) ; let expected_tree = json ! ( [ null { } false ] ) ; // Create and initialise Dag to test let arena : Arena < Json > = Arena :: new ( ) ; let root = add_value_to_arena ( start_tree . clone ( ) , & arena ) ; let start_cursor_location = Path :: from_vec ( vec ! [ 1 0 ] ) ; let expected_cursor_location = Path :: from_vec ( vec ! [ 1 ] ) ; let mut dag = Dag :: new ( & arena , root , start_cursor_location . clone ( ) ) ; // Step 1: Delete TestJson::object's child println ! ( " " ) ; assert_eq ! ( Ok ( EditSuccess Delete { name " " to_string ( ) } ) dag delete_cursor ( 1 ) " " ) ; assert_eq ! ( dag root ( ) expected_tree " " ) ; assert_eq ! ( expected_cursor_location dag current_cursor_path " " ) ; // Perform one undo. println ! ( " " ) ; assert_eq ! ( Ok ( EditSuccess Undo ) dag undo ( 1 ) " " ) ; assert_eq ! ( dag root ( ) start_tree " " ) ; assert_eq ! ( start_cursor_location dag current_cursor_path " " ) ; }
This is the test cases for issue 27
This is the test cases for issue 27