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

Function test_list_encoding_inner

src/repr/src/row.rs:4104–4139  ·  view source on GitHub ↗
(len: usize)

Source from the content-addressed store, hash-verified

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);

Callers 1

test_list_encodingFunction · 0.85

Calls 7

StringClass · 0.85
packerMethod · 0.80
push_list_withMethod · 0.80
unwrapMethod · 0.80
pushMethod · 0.45
iterMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected