Skip to content

Commit

Permalink
Extend reindent_text(..., indent_level). (#1549)
Browse files Browse the repository at this point in the history
  • Loading branch information
1uc authored Nov 6, 2024
1 parent 65a6678 commit fc64097
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions test/unit/utils/test_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ NEURON {
* nmodl, the nmodl output is without "extra" whitespaces in the provided input.
*/

std::string reindent_text(const std::string& text) {
std::string reindent_text(const std::string& text, int indent_level) {
std::string indented_text;
int num_whitespaces = 0;
bool flag = false;
std::string line;
std::stringstream stream(text);
std::string indent(4 * indent_level, ' ');

while (std::getline(stream, line)) {
if (!line.empty()) {
Expand All @@ -71,7 +72,7 @@ std::string reindent_text(const std::string& text) {
}

line.erase(0, num_whitespaces);
indented_text += line;
indented_text += indent + line;
}
/// discard empty lines at very beginning
if (!stream.eof() && flag) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/utils/test_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace nmodl {
namespace test_utils {

std::string reindent_text(const std::string& text);
std::string reindent_text(const std::string& text, int indent_level = 0);

} // namespace test_utils
} // namespace nmodl

0 comments on commit fc64097

Please sign in to comment.