Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sommd opened this issue Jun 29, 2019 · 1 comment · Fixed by #1672
Closed

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

sommd opened this issue Jun 29, 2019 · 1 comment · Fixed by #1672

Comments

@sommd
Copy link
Contributor

sommd commented Jun 29, 2019

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.

@horenmar
Copy link
Member

I am honestly surprised that I didn't make the ChunkGenerator assert on chunk_size == 0.

Anyway, I will have to think about it for a bit -- I am not sure what I think about making the generator potentially infinite even when given a finite generator as an input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants