Aller au contenu principal

CDR2 Golden Vectors

42 golden vectors covering the full XCDR2 type system, published for independent spec compliance verification. Each vector is byte-stable and deterministic (verify mode by default, explicit regen via GOLDEN_REGEN=1).

Encoding: CDR2 Little-Endian (Encapsulation ID 0x000A), per OMG XTypes 1.3 Section 7.4.3.

Vector Catalog​

#VectorType (CDR2)SizeCategory
1primitive_u8uint85 BPrimitives
2primitive_u16uint166 BPrimitives
3primitive_u32uint328 BPrimitives
4primitive_u64uint6412 BPrimitives
5primitive_i8int85 BPrimitives
6primitive_i16int166 BPrimitives
7primitive_i32int328 BPrimitives
8primitive_i64int6412 BPrimitives
9primitive_f32float328 BPrimitives
10primitive_f64float6412 BPrimitives
11primitive_bool_trueboolean5 BPrimitives
12primitive_bool_falseboolean5 BPrimitives
13edge_nanfloat6412 BEdge Cases
14edge_inf_posfloat6412 BEdge Cases
15edge_inf_negfloat6412 BEdge Cases
16edge_u64_maxuint6412 BEdge Cases
17edge_i32_minint328 BEdge Cases
18string_emptystring8 BStrings
19string_hellostring16 BStrings
20string_utf8stringvariesStrings
21string_bounded_256bounded stringvariesStrings
22seq_emptysequence<uint32>8 BSequences
23seq_u32sequence<uint32>variesSequences
24seq_f64sequence<float64>variesSequences
25seq_stringsequence<string>variesSequences
26seq_nestedsequence<sequence<uint32>>variesSequences
27map_emptymap<string, int32>8 BMaps
28map_sortedmap<string, int32>variesMaps
29map_struct_valuemap<string, struct>variesMaps
30struct_point3dstruct Point3DvariesStructs
31struct_labelledstruct LabelledValuevariesStructs
32struct_nestedstruct SegmentvariesStructs
33bool_native_trueboolean (native)5 BNative Booleans
34bool_native_falseboolean (native)5 BNative Booleans
35char8_Achar85 Bchar8
36char8_nullchar85 Bchar8
37array_u32_3uint32[3]16 BFixed-size Arrays
38array_f64_2float64[2]20 BFixed-size Arrays
39optional_some_u32Optional<uint32>variesOptional
40optional_noneOptional<uint32>variesOptional
41optional_some_stringOptional<string>variesOptional
42btreemap_sortedBTreeMap<string, int32>variesBTreeMap

Type Coverage​

CategoryVectorsTypes Covered
Primitives12i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, bool true, bool false
Edge Cases5NaN, +Inf, -Inf, u64::MAX, i32::MIN
Strings4empty, ASCII, UTF-8, bounded 256 chars
Sequences5Vec<u32> empty/populated, Vec<f64>, Vec<String>, Vec<Vec<u32>>
Maps3empty, sorted string->i32, sorted string->struct
Structs3simple Point3D, LabelledValue, nested Segment
Native Booleans2true (0x01), false (0x00)
char82'A', '\0'
Fixed-size Arrays2uint32[3], float64[2]
Optional3Some(u32), None, Some(string)
BTreeMap1deterministic string->i32 (wire-identical to sorted HashMap)

Determinism Guarantees​

  • Sorted-key maps: All map vectors use BTreeMap internally to guarantee deterministic key ordering on the wire
  • Canonical NaN: IEEE 754 canonical NaN (0x7FF8000000000000) used consistently
  • No HashMap in vectors: Only BTreeMap to ensure byte-identical output across runs

How to Use​

  1. Download the .bin files from the golden vectors directory
  2. Serialize your own implementation's output for the same type and value
  3. Compare byte-for-byte against the golden vector
  4. Roundtrip: deserialize the golden .bin and re-serialize, output must match exactly
# Run HDDS golden vector tests
cd crates/hdds
cargo test golden

# Regenerate vectors (maintainers only)
GOLDEN_REGEN=1 cargo test golden

Each vector also has a .hex file with an annotated hex dump for manual inspection.

Downloads​

Golden vectors are available in the HDDS source repository:

crates/hdds/tests/golden/cdr2/