]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add another test.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 21 Dec 2013 14:41:08 +0000 (14:41 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 21 Dec 2013 14:41:08 +0000 (14:41 +0000)
git-svn-id: https://svn.dealii.org/trunk@32083 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/table_03.cc [new file with mode: 0644]
tests/base/table_03.output [new file with mode: 0644]

diff --git a/tests/base/table_03.cc b/tests/base/table_03.cc
new file mode 100644 (file)
index 0000000..77c1644
--- /dev/null
@@ -0,0 +1,71 @@
+// ---------------------------------------------------------------------
+// $Id: table.cc 31349 2013-10-20 19:07:06Z maier $
+//
+// Copyright (C) 1998 - 2013 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.
+//
+// ---------------------------------------------------------------------
+
+
+// check TableBase::fill using an istream_iterator
+
+
+#include "../tests.h"
+#include <cmath>
+#include <fstream>
+#include <iomanip>
+#include <cstdlib>
+
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/table.h>
+
+
+int
+main ()
+{
+  std::ofstream logfile("output");
+  deallog << std::fixed;
+  deallog << std::setprecision(0);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  const std::string elements = "1 2 3 4 5 6";
+  {
+    // create a 2x3 table from this
+    Table<2,double> t (2,3);
+    std::istringstream in1(elements);
+    t.fill (std::istream_iterator<double>(in1),
+           true);
+
+    for (unsigned int i=0; i<t.size()[0]; ++i)
+      {
+       for (unsigned int j=0; j<t.size()[1]; ++j)
+         deallog << t[i][j] << ' ';
+       deallog << std::endl;
+      }
+
+    // same data, same table, but filled in transpose ordering
+    std::istringstream in2(elements);
+    t.fill (std::istream_iterator<double>(in2),
+           false);
+
+    for (unsigned int i=0; i<t.size()[0]; ++i)
+      {
+       for (unsigned int j=0; j<t.size()[1]; ++j)
+         deallog << t[i][j] << ' ';
+       deallog << std::endl;
+      }
+  }
+}
+
+
+
diff --git a/tests/base/table_03.output b/tests/base/table_03.output
new file mode 100644 (file)
index 0000000..f4e57a3
--- /dev/null
@@ -0,0 +1,5 @@
+
+DEAL::1. 2. 3. 
+DEAL::4. 5. 6. 
+DEAL::1. 3. 5. 
+DEAL::2. 4. 6. 

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.