use std::collections::HashMap;
use re_types::{
archetypes::AnnotationContext,
components,
datatypes::{ClassDescription, KeypointPair, Rgba32},
Archetype as _, AsComponents as _,
};
#[test]
fn roundtrip() {
let expected = components::AnnotationContext::from([
(1, "hello").into(),
ClassDescription {
info: (2, "world", Rgba32::from_rgb(3, 4, 5)).into(),
keypoint_annotations: vec![(17, "head").into(), (42, "shoulders").into()],
keypoint_connections: KeypointPair::vec_from([(1, 2), (3, 4)]),
},
]);
let arch = AnnotationContext::new(expected);
let expected_extensions: HashMap<_, _> =
[("context", vec!["rerun.components.AnnotationContext"])].into();
eprintln!("arch = {arch:#?}");
let serialized = arch.to_arrow().unwrap();
for (field, array) in &serialized {
eprintln!("{} = {array:#?}", field.name);
if false {
util::assert_extensions(
&**array,
expected_extensions[field.name.as_str()].as_slice(),
);
}
}
let deserialized = AnnotationContext::from_arrow(serialized).unwrap();
similar_asserts::assert_eq!(arch, deserialized);
}
mod util;