Skip to content

Conversation

@firewave
Copy link
Collaborator

No description provided.

@sonarqubecloud
Copy link

@firewave
Copy link
Collaborator Author

firewave commented Oct 17, 2025

If this is acceptable we probably can use this pattern for other classes which currently require friend declarations to be tested.

Comment on lines +94 to +96
class CmdLineParserTest : public CmdLineParser
{
friend class TestCmdlineParser;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows us to access the protected members.

Copy link
Owner

@danmar danmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no nice solution.

  • Friend is horrible but at least it explicitly pointed out the test class.
  • The disadvantage with this solution is that if we would ever like to use CmdLineParser as a base class in production code then the derived classes have access to stuff that should really be private.

I have no strong opinion. But I fear that sooner or later somebody will come and look at the code and in his opinion we should have solved it in another way and then we get another PR..

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