Skip to content

The first vector returned by ChunkGenerator is size 1 when chunk-size is 0 #1671

@sommd

Description

@sommd

Describe the bug
When using ChunkGenerator with a chunk-size of 0, the first vector returned is size 1. Following vectors are size 0.

Expected behavior
The first (and all following) vectors should be size 0.

Reproduction steps

TEST_CASE("chunks") {
  auto vector = GENERATE(take(5, chunk(0, value(1))));
  REQUIRE(vector.size() == 0);
}

Platform information:

Additional context
My specific use-case in which I ran into this is a test like this:

TEST_CASE("my function") {
  auto size = GENERATE(0, 1, 2, 3);
  auto vector = GENERATE_COPY(take(1, chunk(size, random(-100, 100))));

  auto list = VectorToList(vector);
  
  REQUIRE(list.size() == size);
}

It's possible that the intended behaviour was to return a minimum chunk-size of 1 for all chunks, but I think it would make much more sense to return empty vectors, otherwise the use-case above would be more annoying to write.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions