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

Generalize helpers for indenting and prefixing #14517

Merged
merged 3 commits into from
Oct 13, 2023
Merged

Conversation

cameel
Copy link
Member

@cameel cameel commented Aug 25, 2023

Another refactor related to #14433.

This one comes from the fact that at one point I needed a function to indent a chunk of output and I found several, neither of them accessible to me.

In the end I changed the way expectations are formatted and did not need that function (which is why #14506 does not depend on this refactor) but since I already cleaned this up, I think we should still merge it.

@cameel cameel requested a review from nikola-matic August 25, 2023 20:02
@cameel cameel self-assigned this Aug 25, 2023
Comment on lines 156 to 168
void GasTest::printSource(ostream& _stream, string const& _linePrefix, bool) const
{
string line;
istringstream input(m_source);
while (getline(input, line))
_stream << _linePrefix << line << std::endl;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is superfluous. The inherited version from TestCase does the same thing.

matheusaaguiar
matheusaaguiar previously approved these changes Aug 31, 2023
@cameel cameel force-pushed the indent-refactor branch 2 times, most recently from e52a836 to 78212c1 Compare September 11, 2023 16:07
@cameel cameel force-pushed the indent-refactor branch 3 times, most recently from 6645e92 to bef39cd Compare October 5, 2023 11:57
Copy link
Collaborator

@matheusaaguiar matheusaaguiar left a comment

Choose a reason for hiding this comment

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

LGTM

@cameel cameel enabled auto-merge October 13, 2023 18:23
/// @param _trimPrefix If true, the function avoids introducing trailing whitespace on empty lines.
/// This is achieved by removing trailing spaces from the prefix on such lines.
/// Note that tabs and newlines are not removed, only spaces are.
/// @param _finalNewline If true, an extra \n will be printed at the end of @a _input if it does
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// @param _finalNewline If true, an extra \n will be printed at the end of @a _input if it does
/// @param _finalNewline If true, an extra \n will be printed at the end of @_input if it does

Copy link
Member Author

Choose a reason for hiding this comment

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

What? Is this even a correct doxygen syntax? I think that @ must be followed by a command name.

Well, not that we're following this strictly, but still, this seems incorrect.

/// such lines containing trailing whitespace.
inline std::string indent(std::string const& _input, bool _indentEmptyLines = false)
{
return prefixLines(_input, " ", !_indentEmptyLines);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return prefixLines(_input, " ", !_indentEmptyLines);
return prefixLines(_input, std::string(4, ' '), !_indentEmptyLines);

I think it's clearer this way, at least with regards to the number of spaces in the indentation.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't mind either way, but the PR is merged now so I'll leave it as is (the comment was posted while the PR was already on automerge and I did not notice it in time).

@cameel cameel merged commit 3dab116 into develop Oct 13, 2023
@cameel cameel deleted the indent-refactor branch October 13, 2023 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants