()
| 492 | |
| 493 | #[mz_ore::test] |
| 494 | fn test_sorted_iter_offset() { |
| 495 | let a = Row::pack_slice(&[Datum::String("hello world")]); |
| 496 | let b = Row::pack_slice(&[Datum::UInt32(42)]); |
| 497 | let col = RowCollection::new(vec![(a.clone(), NonZeroUsize::new(3).unwrap())], &[]); |
| 498 | let col = RowCollection::merge_sorted( |
| 499 | &[ |
| 500 | col, |
| 501 | RowCollection::new(vec![(b.clone(), NonZeroUsize::new(2).unwrap())], &[]), |
| 502 | ], |
| 503 | &[], |
| 504 | ); |
| 505 | |
| 506 | // Test with a reasonable offset that does not span rows. |
| 507 | let mut iter = col.into_row_iter().apply_offset(1); |
| 508 | assert_eq!(iter.next(), Some(b.borrow())); |
| 509 | assert_eq!(iter.next(), Some(a.borrow())); |
| 510 | assert_eq!(iter.next(), Some(a.borrow())); |
| 511 | assert_eq!(iter.next(), Some(a.borrow())); |
| 512 | assert_eq!(iter.next(), None); |
| 513 | assert_eq!(iter.next(), None); |
| 514 | |
| 515 | let col = iter.into_inner(); |
| 516 | |
| 517 | // Test with an offset that spans the first row. |
| 518 | let mut iter = col.into_row_iter().apply_offset(3); |
| 519 | |
| 520 | assert_eq!(iter.peek(), Some(a.borrow())); |
| 521 | |
| 522 | assert_eq!(iter.next(), Some(a.borrow())); |
| 523 | assert_eq!(iter.next(), Some(a.borrow())); |
| 524 | assert_eq!(iter.next(), None); |
| 525 | assert_eq!(iter.next(), None); |
| 526 | |
| 527 | let col = iter.into_inner(); |
| 528 | |
| 529 | // Test with an offset that passes the entire collection. |
| 530 | let mut iter = col.into_row_iter().apply_offset(100); |
| 531 | assert_eq!(iter.peek(), None); |
| 532 | assert_eq!(iter.next(), None); |
| 533 | assert_eq!(iter.peek(), None); |
| 534 | assert_eq!(iter.next(), None); |
| 535 | } |
| 536 | |
| 537 | #[mz_ore::test] |
| 538 | fn test_sorted_iter_limit() { |
nothing calls this directly
no test coverage detected