diff options
| -rw-r--r-- | common/object/src/tests.rs | 12 | ||||
| -rw-r--r-- | common/object/src/value.rs | 1 |
2 files changed, 12 insertions, 1 deletions
diff --git a/common/object/src/tests.rs b/common/object/src/tests.rs index 59e6d8c..616ac69 100644 --- a/common/object/src/tests.rs +++ b/common/object/src/tests.rs @@ -4,7 +4,7 @@ Copyright (C) 2026 metamuffin <metamuffin.org> */ -use crate::{ObjectBuffer, Registry, fields, inspect::Inspector}; +use crate::{Object, ObjectBuffer, Registry, fields, inspect::Inspector}; use std::sync::LazyLock; pub static TAGREG: LazyLock<Registry> = LazyLock::new(|| { @@ -16,6 +16,7 @@ fields! { NAME: &str = 15 "name"; AGE: u32 = 13 "age"; FRIEND: &str = 54321 "friend"; + STUFF: Object = 3 "stuff"; } fn test_object() -> ObjectBuffer { @@ -76,6 +77,15 @@ fn insert() { } #[test] +fn insert_empty() { + let ob = Object::EMPTY.insert(NAME, "Romeo"); + assert_eq!(ob.as_object().get(NAME), Some("Romeo")); + + let ob = Object::EMPTY.insert(STUFF, Object::EMPTY); + assert_eq!(ob.as_object().get(STUFF), Some(Object::EMPTY)); +} + +#[test] fn inspect_object() { let bob = test_object(); eprintln!("{:#?}", Inspector(&TAGREG, bob.as_object())); diff --git a/common/object/src/value.rs b/common/object/src/value.rs index cf6dad2..ac4cc9d 100644 --- a/common/object/src/value.rs +++ b/common/object/src/value.rs @@ -139,6 +139,7 @@ impl ValueStore for Object<'_> { true } fn store_aligned(&self, buf: &mut Vec<u32>) { + buf.push(self.tags.len() as u32); buf.extend(self.tags); buf.extend(self.offsets); buf.extend(self.values); |