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

tests: Add unit tests for repeated_chars_iterator #29

Merged
merged 2 commits into from
Nov 15, 2024

Conversation

RaduNichita
Copy link
Contributor

Added two more unit tests to the suite:

  • one to test the std::next function on a beman iterator
  • one to test the std::distance function on a beman iterator

@camio
Copy link
Member

camio commented Nov 14, 2024

Could these tests be made constexpr with static_assert?

@steve-downey
Copy link
Member

constexpr can involve different code paths in the implementation, so the tests should generally be both consteval and runtime. I think?

I'm still working out understanding of constexpr testing and testing constexpr code.

@neatudarius
Copy link
Member

I would also add tests for concepts like in https://github.com/beman-project/optional26/blob/main/src/beman/optional26/tests/detail/iterator.t.cpp

@neatudarius
Copy link
Member

constexpr can involve different code paths in the implementation, so the tests should generally be both consteval and runtime. I think?

I'm still working out understanding of constexpr testing and testing constexpr code.

https://github.com/beman-project/optional26/blob/main/src/beman/optional26/tests/detail/iterator.t.cpp#L18C9-L18C28

@steve-downey , is the same solution that we already have in this file in optional26? Is there any other "better" utility?

@steve-downey
Copy link
Member

constexpr can involve different code paths in the implementation, so the tests should generally be both consteval and runtime. I think?

I'm still working out understanding of constexpr testing and testing constexpr code.

https://github.com/beman-project/optional26/blob/main/src/beman/optional26/tests/detail/iterator.t.cpp#L18C9-L18C28

@steve-downey , is the same solution that we already have in this file in optional26? Is there any other "better" utility?

Looking at that, I'm not 100% sure that's actually consteval? That macro looks like it would work in a constexpr context, but it would also work at runtime?
Also need to be sure that, for example, we could iterate an array in a consteval function using one of these? Or a constexpr vector, if the compiler will let us?
And, hopefully, still produce a junit report so the dashboard is green, or the appropriate test is visibly failing?

Failing to compile is a draconian error and we don't get any other test results.

@RaduNichita RaduNichita merged commit c935543 into bemanproject:main Nov 15, 2024
7 checks passed
@neatudarius
Copy link
Member

Link this PR against #5

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

Successfully merging this pull request may close these issues.

4 participants