diff options
Diffstat (limited to 'crdt/src/lib.rs')
| -rw-r--r-- | crdt/src/lib.rs | 62 |
1 files changed, 43 insertions, 19 deletions
diff --git a/crdt/src/lib.rs b/crdt/src/lib.rs index c0214b3..39c5f0e 100644 --- a/crdt/src/lib.rs +++ b/crdt/src/lib.rs @@ -216,32 +216,56 @@ mod tests { }, ); - let realized = doc.realize().unwrap(); + { + let realized = doc.realize().unwrap(); - assert!(realized.grids.len() == 1); + assert!(realized.grids.len() == 1); - let grid = realized.grids.first().unwrap(); + let grid = realized.grids.first().unwrap(); - assert!(grid.rows.len() == 4); + assert!(grid.rows.len() == 4); - let row = grid.rows.first().unwrap(); + let row = grid.rows.first().unwrap(); - assert!(row.cells.len() == 16); + assert!(row.cells.len() == 16); - doc.append_op( - &actor_id, - OpPayload::ChangeSubdivisions { - grid_id: grid.id.clone(), - row_id: row.id.clone(), - start_cell_id: row.cells[0].id.clone(), - end_cell_id: row.cells[3].id.clone(), - subdivisions: 3, - }, - ); + doc.append_op( + &actor_id, + OpPayload::ChangeSubdivisions { + grid_id: grid.id.clone(), + row_id: row.id.clone(), + start_cell_id: row.cells[0].id.clone(), + end_cell_id: row.cells[3].id.clone(), + subdivisions: 3, + }, + ); + } - let realized2 = doc.realize().unwrap(); + { + let realized = doc.realize().unwrap(); + + assert_eq!(realized.grids[0].rows[0].cells.len(), 15); + assert_eq!(realized.grids[0].rows[1].cells.len(), 16); + + let grid = &realized.grids[0]; + let row = &grid.rows[0]; + + doc.append_op( + &actor_id, + OpPayload::ChangeSubdivisions { + grid_id: grid.id.clone(), + row_id: row.id.clone(), + start_cell_id: row.cells[0].id.clone(), + end_cell_id: row.cells.last().unwrap().id.clone(), + subdivisions: 12, + }, + ); + } - assert_eq!(realized2.grids[0].rows[0].cells.len(), 15); - assert_eq!(realized2.grids[0].rows[1].cells.len(), 16); + { + let realized = doc.realize().unwrap(); + assert_eq!(realized.grids[0].rows[0].cells.len(), 12); + assert_eq!(realized.grids[0].rows[1].cells.len(), 16); + } } } |
