util: Avoid output duplication in IndentedStream

Change-Id: Ia530878068da89a1839574c9c5f1dc5d1de8b54e
Fixes: #2723
diff --git a/tests/unit-tests/util/indented-stream.t.cpp b/tests/unit-tests/util/indented-stream.t.cpp
index 30d2e07..91dff26 100644
--- a/tests/unit-tests/util/indented-stream.t.cpp
+++ b/tests/unit-tests/util/indented-stream.t.cpp
@@ -52,6 +52,26 @@
                           ));
 }
 
+BOOST_AUTO_TEST_CASE(BasicWithFlushes) // Bug #2723
+{
+  output_test_stream os;
+
+  os << "Hello" << std::endl;
+  {
+    IndentedStream os1(os, " [prefix] ");
+    os1 << "," << std::endl;
+    {
+      IndentedStream os2(os1, " [another prefix] ");
+      os2 << "World!" << std::endl;
+    }
+  }
+
+  BOOST_CHECK(os.is_equal("Hello\n"
+                          " [prefix] ,\n"
+                          " [prefix]  [another prefix] World!\n"
+                          ));
+}
+
 BOOST_AUTO_TEST_SUITE_END()
 
 } // namespace tests