| 871 | use super::*; |
| 872 | |
| 873 | fn do_read( |
| 874 | buf: &str, |
| 875 | batch_size: usize, |
| 876 | coerce_primitive: bool, |
| 877 | strict_mode: bool, |
| 878 | schema: SchemaRef, |
| 879 | ) -> Vec<RecordBatch> { |
| 880 | let mut unbuffered = vec![]; |
| 881 | |
| 882 | // Test with different batch sizes to test for boundary conditions |
| 883 | for batch_size in [1, 3, 100, batch_size] { |
| 884 | unbuffered = ReaderBuilder::new(schema.clone()) |
| 885 | .with_batch_size(batch_size) |
| 886 | .with_coerce_primitive(coerce_primitive) |
| 887 | .build(Cursor::new(buf.as_bytes())) |
| 888 | .unwrap() |
| 889 | .collect::<Result<Vec<_>, _>>() |
| 890 | .unwrap(); |
| 891 | |
| 892 | for b in unbuffered.iter().take(unbuffered.len() - 1) { |
| 893 | assert_eq!(b.num_rows(), batch_size) |
| 894 | } |
| 895 | |
| 896 | // Test with different buffer sizes to test for boundary conditions |
| 897 | for b in [1, 3, 5] { |
| 898 | let buffered = ReaderBuilder::new(schema.clone()) |
| 899 | .with_batch_size(batch_size) |
| 900 | .with_coerce_primitive(coerce_primitive) |
| 901 | .with_strict_mode(strict_mode) |
| 902 | .build(BufReader::with_capacity(b, Cursor::new(buf.as_bytes()))) |
| 903 | .unwrap() |
| 904 | .collect::<Result<Vec<_>, _>>() |
| 905 | .unwrap(); |
| 906 | assert_eq!(unbuffered, buffered); |
| 907 | } |
| 908 | } |
| 909 | |
| 910 | unbuffered |
| 911 | } |
| 912 | |
| 913 | #[test] |
| 914 | fn test_basic() { |