(len: usize)
| 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); |
no test coverage detected