]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add test. 4240/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Mon, 10 Apr 2017 01:37:34 +0000 (19:37 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Mon, 10 Apr 2017 01:37:34 +0000 (19:37 -0600)
tests/base/table_handler_14.cc [new file with mode: 0644]
tests/base/table_handler_14.output [new file with mode: 0644]

diff --git a/tests/base/table_handler_14.cc b/tests/base/table_handler_14.cc
new file mode 100644 (file)
index 0000000..9b83809
--- /dev/null
@@ -0,0 +1,65 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2010 - 2015, 2017 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// test TableHandler::start_new_row()
+
+
+#include "../tests.h"
+#include <deal.II/base/data_out_base.h>
+#include <deal.II/base/table_handler.h>
+#include <deal.II/base/logstream.h>
+
+#include <vector>
+#include <iomanip>
+#include <fstream>
+#include <string>
+
+
+int main ()
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.threshold_double(1.e-10);
+
+  TableHandler table;
+  table.set_auto_fill_mode (true);
+
+  std::string keys[3] = { "key1", "key2", "key3" };
+
+  // fill rows 1 and 2 partially
+  table.add_value(keys[0], 0);
+  table.add_value(keys[0], 1);
+
+  // now fill row 3 completely, using auto_fill_mode
+  table.add_value(keys[0], 2);
+  table.add_value(keys[1], 113);
+  table.add_value(keys[2], std::string("a"));
+
+  // now again fill row 4 partially
+  table.add_value(keys[0], 1);
+
+  // and start a new row that also fills the remaining columns
+  table.start_new_row ();
+
+  // do it again:
+  table.add_value(keys[0], 2);
+  table.start_new_row ();
+
+  // produce output. hope that row 4 is
+  // completely padded
+  table.write_text(deallog.get_file_stream(),
+                   TableHandler::org_mode_table);
+}
diff --git a/tests/base/table_handler_14.output b/tests/base/table_handler_14.output
new file mode 100644 (file)
index 0000000..4059e24
--- /dev/null
@@ -0,0 +1,7 @@
+
+| key1 | key2 | key3 | 
+| 0    | 0    | ""   | 
+| 1    | 0    | ""   | 
+| 2    | 113  | a    | 
+| 1    | ""   | ""   | 
+| 2    | ""   | ""   | 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.