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

Add test for Storage::append() with reallocation #509

Merged
merged 3 commits into from
Nov 19, 2024

Conversation

IvanaGyro
Copy link
Collaborator

This PR also extends the test coverage of Storage::fill().

@IvanaGyro IvanaGyro marked this pull request as draft November 12, 2024 19:21
Sometimes we want to create a test case testing with all combinations of
the supported data types. There is a test checking if the value of
each data type can be filled into the `Storage` instance storing the
values in every supported data type. One way to make this kind of test
case but not to duplicate the test cases for each combination of types
is to use gtest's typed-test feature which needs us to list all
combinations of types.

```cpp
using MyTypes = ::testing::Types<std::pair<int, double>,
                                 std::pair<int, bool>,
                                 std::pair<double, double>,
                                 std::pair<double, bool>>;
TYPED_TEST_SUITE(MyFixture, MyTypes);
TYPED_TEST(TestSuiteName, TestName) {
  using FirstType = TypeParam::first_type;
  using SecondType = TypeParam::second_type;
  //...
}
```

In the example `MyTypes` contains the combination of two groups of
types. The first group is `int` and `double`, and the second group is
`double` and `bool`. If there are ten supported types, there will be one
hundred pairs in `MyTypes`. Writing that kind of code is exhausting,
and the code will be hard to maintain.

This change provides a tool for generating all combinations of the given
testing types and makes writing tests more easily.
The previous tests were limited to integral data types. The new tests
verify that filling all Storage types with a value of any supported data
type behaves correctly.
Test with all Storage types and all data types.
Copy link

codecov bot commented Nov 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 18.11%. Comparing base (17a6edf) to head (c7effd2).
Report is 8 commits behind head on dev-master.

Additional details and impacted files
@@              Coverage Diff               @@
##           dev-master     #509      +/-   ##
==============================================
+ Coverage       16.78%   18.11%   +1.33%     
==============================================
  Files             221      221              
  Lines           53173    53173              
  Branches        19822    19823       +1     
==============================================
+ Hits             8923     9634     +711     
+ Misses          39940    39003     -937     
- Partials         4310     4536     +226     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@IvanaGyro IvanaGyro marked this pull request as ready for review November 14, 2024 08:12
@IvanaGyro IvanaGyro changed the base branch from dev-master to master November 14, 2024 08:13
@IvanaGyro IvanaGyro changed the base branch from master to dev-master November 14, 2024 08:13
@IvanaGyro IvanaGyro merged commit 0b510a6 into dev-master Nov 19, 2024
4 checks passed
@IvanaGyro IvanaGyro deleted the test-storage-append branch November 19, 2024 02:56
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.

2 participants