Skip to content

Commit

Permalink
StateVector: add real case of comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
Horusiath committed Sep 2, 2024
1 parent 8756aa5 commit 7cec6d9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion yrs/src/state_vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ impl Decode for Snapshot {

#[cfg(test)]
mod test {
use crate::StateVector;
use crate::{Doc, ReadTxn, StateVector, Text, Transact, WriteTxn};
use std::cmp::Ordering;
use std::iter::FromIterator;

Expand Down Expand Up @@ -246,4 +246,16 @@ mod test {
let b = StateVector::default();
assert_eq!(a.partial_cmp(&b), Some(Ordering::Equal));
}

#[test]
fn ordering_one_of() {
let doc = Doc::with_client_id(1);
let mut txn = doc.transact_mut();
let txt = txn.get_or_insert_text("text");
txt.insert(&mut txn, 0, "a");

let a = txn.state_vector();
let b = StateVector::default();
assert_eq!(a.partial_cmp(&b), Some(Ordering::Greater));
}
}

0 comments on commit 7cec6d9

Please sign in to comment.