| 343 | |
| 344 | #[mz_ore::test] |
| 345 | fn small_zero_width_record_array_decodes() { |
| 346 | // The node cap must not reject an ordinary, below-cap array of zero-width |
| 347 | // records: ten `record{null}`s encode (like `array<null>`) as just the |
| 348 | // block count followed by the terminating zero block. |
| 349 | use std::str::FromStr; |
| 350 | |
| 351 | use super::{AvroDeserializer, GeneralDeserializer}; |
| 352 | use crate::types::Value; |
| 353 | use crate::util::zig_i64; |
| 354 | use crate::{Schema, ValueDecoder}; |
| 355 | |
| 356 | let schema = Schema::from_str( |
| 357 | r#"{"type": "array", "items": |
| 358 | {"type": "record", "name": "R", "fields": [{"name": "g0", "type": "null"}]}}"#, |
| 359 | ) |
| 360 | .unwrap(); |
| 361 | let mut body = Vec::new(); |
| 362 | zig_i64(10, &mut body); |
| 363 | body.push(0); |
| 364 | let dsr = GeneralDeserializer { |
| 365 | schema: schema.top_node(), |
| 366 | }; |
| 367 | let mut reader: &[u8] = &body; |
| 368 | let decoded = dsr |
| 369 | .deserialize(&mut reader, ValueDecoder) |
| 370 | .expect("a below-cap array of zero-width records must decode, not be rejected"); |
| 371 | let want = Value::Record(vec![("g0".to_string(), Value::Null)]); |
| 372 | assert_eq!(decoded, Value::Array(vec![want; 10])); |
| 373 | } |
| 374 | |
| 375 | #[mz_ore::test] |
| 376 | fn nested_zero_width_collection_shares_node_budget() { |