cultcache-rs: pin removal and UTF-16 order of the moved-store keys
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8fbe38bcbc
commit
d61216dd62
1 changed files with 23 additions and 0 deletions
|
|
@ -1025,3 +1025,26 @@ fn registering_without_the_index_releases_the_holders() {
|
|||
cache.put("b", &Twin { sku: "S".into(), category: "x".into() }).unwrap();
|
||||
assert!(cache.register_entry_type::<Unique>().is_err(), "the duplicate now written is a held violation");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_record_another_writer_removed_or_added_moves_the_store_and_the_keys_come_back_in_utf16_order() {
|
||||
for kind in ["single", "redb", "owned"] {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let kind = kinds(dir.path()).into_iter().find(|(name, _)| *name == kind).unwrap().1;
|
||||
let mut seed = reader(&kind, dir.path());
|
||||
seed.put("a", &Plain { value: "gone soon".into() }).unwrap();
|
||||
let mut second = reader(&kind, dir.path());
|
||||
let mut other = reader(&kind, dir.path());
|
||||
|
||||
// A removal alone moves the store.
|
||||
assert!(other.delete::<Plain>("a").unwrap());
|
||||
assert_eq!(conflict_of(&second.put("c", &unique("fresh")).unwrap_err()).changed_keys, ["a"]);
|
||||
assert!(second.get::<Plain>("a").unwrap().is_none(), "the removal is loaded");
|
||||
|
||||
// Keys sort by UTF-16 code unit: b, then the astral U+10400 (D801 DC00), then U+FF21.
|
||||
for key in ["\u{ff21}", "\u{10400}", "b"] {
|
||||
other.put(key, &Plain { value: "x".into() }).unwrap();
|
||||
}
|
||||
assert_eq!(conflict_of(&second.put("c", &unique("fresh")).unwrap_err()).changed_keys, ["b", "\u{10400}", "\u{ff21}"]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue