mirror of
https://github.com/loro-dev/loro.git
synced 2025-02-06 04:19:34 +00:00
test: add import history data test
This commit is contained in:
parent
1d3cd60873
commit
4ecd850632
3 changed files with 10 additions and 3 deletions
|
@ -369,16 +369,17 @@ impl OpLog {
|
|||
for change in changes.iter() {
|
||||
if change.id.counter < 0 {
|
||||
return Err(LoroError::DecodeError(
|
||||
"Invalid data".to_string().into_boxed_str(),
|
||||
"Invalid data. Negative id counter.".into(),
|
||||
));
|
||||
}
|
||||
if let Some(last_end_counter) = &mut last_end_counter {
|
||||
if change.id.counter != *last_end_counter {
|
||||
*last_end_counter = change.id_end().counter;
|
||||
return Err(LoroError::DecodeError(
|
||||
"Invalid data".to_string().into_boxed_str(),
|
||||
"Invalid data. Not continuous counter.".into(),
|
||||
));
|
||||
}
|
||||
|
||||
*last_end_counter = change.id_end().counter;
|
||||
} else {
|
||||
last_end_counter = Some(change.id_end().counter);
|
||||
}
|
||||
|
|
BIN
crates/loro-internal/tests/history_data_v1.dat
Normal file
BIN
crates/loro-internal/tests/history_data_v1.dat
Normal file
Binary file not shown.
|
@ -19,6 +19,12 @@ fn import() {
|
|||
.unwrap_or_default();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn import_history() {
|
||||
let doc = LoroDoc::new();
|
||||
doc.import(include_bytes!("./history_data_v1.dat")).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_timestamp() {
|
||||
let doc = LoroDoc::new();
|
||||
|
|
Loading…
Reference in a new issue