MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / test_list_encoding

Function test_list_encoding

src/repr/src/row.rs:4103–4150  ·  view source on GitHub ↗

slow

()

Source from the content-addressed store, hash-verified

4101 #[mz_ore::test]
4102 #[cfg_attr(miri, ignore)] // slow
4103 fn test_list_encoding() {
4104 fn test_list_encoding_inner(len: usize) {
4105 let list_elem = |i: usize| {
4106 if i % 2 == 0 {
4107 Datum::False
4108 } else {
4109 Datum::True
4110 }
4111 };
4112 let mut row = Row::default();
4113 {
4114 // Push some stuff.
4115 let mut packer = row.packer();
4116 packer.push(Datum::String("start"));
4117 packer.push_list_with(|packer| {
4118 for i in 0..len {
4119 packer.push(list_elem(i));
4120 }
4121 });
4122 packer.push(Datum::String("end"));
4123 }
4124 // Check that we read back exactly what we pushed.
4125 let mut row_it = row.iter();
4126 assert_eq!(row_it.next().unwrap(), Datum::String("start"));
4127 match row_it.next().unwrap() {
4128 Datum::List(list) => {
4129 let mut list_it = list.iter();
4130 for i in 0..len {
4131 assert_eq!(list_it.next().unwrap(), list_elem(i));
4132 }
4133 assert_none!(list_it.next());
4134 }
4135 _ => panic!("expected Datum::List"),
4136 }
4137 assert_eq!(row_it.next().unwrap(), Datum::String("end"));
4138 assert_none!(row_it.next());
4139 }
4140
4141 test_list_encoding_inner(0);
4142 test_list_encoding_inner(1);
4143 test_list_encoding_inner(10);
4144 test_list_encoding_inner(TINY - 1); // tiny
4145 test_list_encoding_inner(TINY + 1); // short
4146 test_list_encoding_inner(SHORT + 1); // long
4147
4148 // The biggest one takes 40 s on my laptop, probably not worth it.
4149 //test_list_encoding_inner(LONG + 1); // huge
4150 }
4151
4152 /// Demonstrates that DatumList's Eq (bytewise) and Ord (datum-by-datum) are now consistent.
4153 /// A list containing -0.0 and one containing +0.0 have different byte representations

Callers

nothing calls this directly

Calls 1

test_list_encoding_innerFunction · 0.85

Tested by

no test coverage detected