Compare commits
1 Commits
dani/widge
...
feature/ni
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d189905ba |
12
base/src/garbage_collector.rs
Normal file
12
base/src/garbage_collector.rs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
use crate::model::Model;
|
||||||
|
|
||||||
|
// The gc (Garbage Collector) cleans up leftover elements in the workbook:
|
||||||
|
// * Strings that are no longe reachable
|
||||||
|
// * Styles that are no longer reachable
|
||||||
|
// * ...
|
||||||
|
|
||||||
|
impl Model {
|
||||||
|
pub(crate) fn gc(&mut self) -> Result<(), String> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -50,6 +50,7 @@ mod implicit_intersection;
|
|||||||
mod units;
|
mod units;
|
||||||
mod utils;
|
mod utils;
|
||||||
mod workbook;
|
mod workbook;
|
||||||
|
mod garbage_collector;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test;
|
mod test;
|
||||||
|
|||||||
@@ -53,3 +53,4 @@ mod test_frozen_rows_and_columns;
|
|||||||
mod test_get_cell_content;
|
mod test_get_cell_content;
|
||||||
mod test_percentage;
|
mod test_percentage;
|
||||||
mod test_today;
|
mod test_today;
|
||||||
|
mod test_gc;
|
||||||
|
|||||||
22
base/src/test/test_gc.rs
Normal file
22
base/src/test/test_gc.rs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#![allow(clippy::unwrap_used)]
|
||||||
|
|
||||||
|
use crate::test::util::new_empty_model;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_empty_model() {
|
||||||
|
let mut model = new_empty_model();
|
||||||
|
// set a string
|
||||||
|
model._set("A1", "Hello");
|
||||||
|
assert_eq!(model.shared_strings.len(), 1);
|
||||||
|
// calling the gc doesn't do anything
|
||||||
|
model.gc().unwrap();
|
||||||
|
assert_eq!(model.shared_strings.len(), 1);
|
||||||
|
|
||||||
|
// If we delete the cell the string is still in the list
|
||||||
|
model.delete_cell(0, 1, 1).unwrap();
|
||||||
|
assert_eq!(model.shared_strings.len(), 1);
|
||||||
|
|
||||||
|
// after the gc the string is no longer present
|
||||||
|
model.gc().unwrap();
|
||||||
|
assert_eq!(model.shared_strings.len(), 0);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user