| 526 | } |
| 527 | |
| 528 | void TestOverflow() { |
| 529 | const int64_t kMaxIndex = std::is_signed_v<IndexType> ? 127 : 255; |
| 530 | std::vector<IndexType> logical_index_vec = {0, 1, 2, |
| 531 | static_cast<IndexType>(kMaxIndex)}; |
| 532 | |
| 533 | // Overflows are rare because to make them possible, we need more chunks |
| 534 | // than logical elements in the ChunkedArray. That requires at least one |
| 535 | // empty chunk. |
| 536 | std::vector<int64_t> offsets; |
| 537 | for (int64_t i = 0; i <= kMaxIndex; i++) { |
| 538 | offsets.push_back(i); |
| 539 | } |
| 540 | ChunkResolver resolver{offsets}; |
| 541 | ASSERT_OK(ResolveMany(resolver, logical_index_vec)); |
| 542 | |
| 543 | offsets.push_back(kMaxIndex); // adding an empty chunk |
| 544 | ChunkResolver resolver_with_empty{offsets}; |
| 545 | if (sizeof(IndexType) == 1) { |
| 546 | ASSERT_NOT_OK(ResolveMany(resolver_with_empty, logical_index_vec)); |
| 547 | } else { |
| 548 | ASSERT_OK(ResolveMany(resolver_with_empty, logical_index_vec)); |
| 549 | } |
| 550 | } |
| 551 | |
| 552 | void TestRandomInput(int32_t num_chunks, int64_t chunked_array_len) { |
| 553 | random::pcg64 rng(42); |
nothing calls this directly
no test coverage detected