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

Public Classes: Final or Test as Derived #1113

Open
ax3l opened this issue Sep 22, 2021 · 2 comments
Open

Public Classes: Final or Test as Derived #1113

ax3l opened this issue Sep 22, 2021 · 2 comments

Comments

@ax3l
Copy link
Member

ax3l commented Sep 22, 2021

In #1107, we realized that we should add final for our user-facing public classes or add a test that derives from them and uses them in derived classes.

@franzpoeschel
Copy link
Contributor

franzpoeschel commented Sep 23, 2021

How should we go about this? Testing things like these is unfortunately not as simple as just deriving from the class and using it once. Unless we had full test coverage for a derived-from Series class, this bug would have probably not shown, since it occurs only at runtime as soon as the function SeriesInterface::readIterations() is called.
Essentially, this issue asks to duplicate nearly our complete test suite for derived-from classes.

The only thing that I can imagine for now would be something like:

#include <openPMD/openPMD.hpp>
// do *not* do something like `using namespace openPMD;`
class Series : public openPMD::Series
{
// make all constructors of openPMD::Series available
template< typename ...Args >
Series( Args&&... args) : openPMD::Series{ std::forward< Args >( args )... }
{}
};

(I haven't yet tested if that would actually catch the bug in #1107)

And pull that same trick for all other classes or class templates that we have. Also, don't use auto anywhere in the tests, so we make sure that everywhere uses those derived classes. If there's one code path not covered, that one could be where something like object slicing would happen.

@ax3l
Copy link
Member Author

ax3l commented Oct 12, 2021

I would say then let's mark them all as final for now.
There is no real need to derive from them. People can still wrap them in members.

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

No branches or pull requests

2 participants