From a1df8c362f2adffaa688549f1b5677632fc79dcf Mon Sep 17 00:00:00 2001 From: Luc Grosheintz Date: Tue, 5 Nov 2024 14:25:22 +0100 Subject: [PATCH] Extend `reindent_text(..., indent_level)`. --- test/unit/utils/test_utils.cpp | 5 +++-- test/unit/utils/test_utils.hpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/unit/utils/test_utils.cpp b/test/unit/utils/test_utils.cpp index c9d9ee367..431bbac02 100644 --- a/test/unit/utils/test_utils.cpp +++ b/test/unit/utils/test_utils.cpp @@ -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()) { @@ -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) { diff --git a/test/unit/utils/test_utils.hpp b/test/unit/utils/test_utils.hpp index 22355b761..5bc9b7adb 100644 --- a/test/unit/utils/test_utils.hpp +++ b/test/unit/utils/test_utils.hpp @@ -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