()
| 232 | |
| 233 | #[test] |
| 234 | fn test_offset_buffer() { |
| 235 | let mut buffer = OffsetBuffer::<i32>::with_capacity(0); |
| 236 | for v in ["hello", "world", "cupcakes", "a", "b", "c"] { |
| 237 | buffer.try_push(v.as_bytes(), false).unwrap() |
| 238 | } |
| 239 | let split = std::mem::replace(&mut buffer, OffsetBuffer::with_capacity(0)); |
| 240 | |
| 241 | let array = split.into_array(None, ArrowType::Utf8); |
| 242 | let strings = array.as_any().downcast_ref::<StringArray>().unwrap(); |
| 243 | assert_eq!( |
| 244 | strings.iter().map(|x| x.unwrap()).collect::<Vec<_>>(), |
| 245 | vec!["hello", "world", "cupcakes", "a", "b", "c"] |
| 246 | ); |
| 247 | |
| 248 | buffer.try_push("test".as_bytes(), false).unwrap(); |
| 249 | let array = buffer.into_array(None, ArrowType::Utf8); |
| 250 | let strings = array.as_any().downcast_ref::<StringArray>().unwrap(); |
| 251 | assert_eq!( |
| 252 | strings.iter().map(|x| x.unwrap()).collect::<Vec<_>>(), |
| 253 | vec!["test"] |
| 254 | ); |
| 255 | } |
| 256 | |
| 257 | #[test] |
| 258 | fn test_offset_buffer_pad_nulls() { |
nothing calls this directly
no test coverage detected