]> www.ginac.de Git - ginac.git/commitdiff
added check for archiving system
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Fri, 6 Apr 2001 23:02:12 +0000 (23:02 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Fri, 6 Apr 2001 23:02:12 +0000 (23:02 +0000)
check/Makefile.am
check/exam_archive.cpp [new file with mode: 0644]
check/exams.cpp
check/exams.h
check/exams.ref

index fb943d0b663e9143e524993bb9d048ff53c4d12b..459799eba7dcf0694cd124a0b0802a489687e3a2 100644 (file)
@@ -10,8 +10,8 @@ checks_LDADD = ../ginac/libginac.la
 exams_SOURCES = exam_paranoia.cpp exam_numeric.cpp exam_powerlaws.cpp \
   exam_inifcns.cpp exam_differentiation.cpp exam_polygcd.cpp \
   exam_normalization.cpp exam_pseries.cpp exam_matrices.cpp exam_lsolve.cpp \
-  exam_indexed.cpp exam_color.cpp exam_clifford.cpp exam_misc.cpp exams.cpp \
-  exams.h
+  exam_indexed.cpp exam_color.cpp exam_clifford.cpp exam_archive.cpp \
+  exam_misc.cpp exams.cpp exams.h
 exams_LDADD = ../ginac/libginac.la
 
 times_SOURCES = time_dennyfliegner.cpp time_gammaseries.cpp \
diff --git a/check/exam_archive.cpp b/check/exam_archive.cpp
new file mode 100644 (file)
index 0000000..af8f490
--- /dev/null
@@ -0,0 +1,80 @@
+/** @file exam_archive.cpp
+ *
+ *  Here we test GiNaC's archiving system. */
+
+/*
+ *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "exams.h"
+
+#include <fstream>
+
+unsigned exam_archive(void)
+{
+       unsigned result = 0;
+       
+       cout << "examining archiving system" << flush;
+       clog << "----------archiving system:" << endl;
+
+       symbol x("x"), y("y"), mu("mu"), dim("dim");
+       ex e, f;
+
+       // This expression is complete nonsense but it contains every type of
+       // GiNaC object
+       e = -42 * x * pow(y, sin(y*Catalan)) * dirac_one()
+           * epsilon_tensor(idx(fail(), 3), idx(0, 3), idx(y/2, 3))
+         + lorentz_g(
+             varidx(lst(x, -11*y, acos(2*x).series(x==3-5*I, 3)) * color_ONE()
+               * metric_tensor(varidx(0, 5), varidx(2, 4)), zeta(3)),
+             varidx(diag_matrix(lst(-1, Euler, atan(x/y==-15*I/17)))
+               * delta_tensor(idx(x, 2), idx(y, 3)), log(cos(128.0/(x*y))), true),
+             true
+           )
+         + dirac_gamma(varidx(mu, dim)) * dirac_gamma(varidx(mu, 4-dim, true))
+           * color_T(idx(x, 8), 1) * color_h(idx(x, 8), idx(y, 8), idx(2, 8))
+           * indexed(x, indexed::antisymmetric, idx(2*y+1, x), varidx(-mu, 5))
+         + 0.775;
+
+       archive ar;
+       ar.archive_ex(e, "expr 1");
+       {
+               std::ofstream fout("exam.gar");
+               fout << ar;
+       }
+       ar.clear();
+       {
+               std::ifstream fin("exam.gar");
+               fin >> ar;
+       }
+       f = ar.unarchive_ex(lst(x, y, mu, dim), "expr 1");
+
+       if (!f.is_equal(e)) {
+               clog << "archiving/unarchiving " << e << endl
+                    << "erroneously returned " << f << endl;
+               ++result;
+       }
+       
+       if (!result) {
+               cout << " passed " << endl;
+               clog << "(no output)" << endl;
+       } else {
+               cout << " failed " << endl;
+       }
+       
+       return result;
+}
index b4ec8cb4be17ffe1ea11b708a108961ea1504150..41097741b669f103272981ac58de607f3192fa62 100644 (file)
@@ -50,6 +50,7 @@ try { \
        EXAM(indexed)
        EXAM(color)
        EXAM(clifford)
+       EXAM(archive)
        EXAM(misc)
        
        if (result) {
index ae454e40505e2622d862fdd7a5778555fe3b3fc8..1372cc30a76fcc3a69bf9b0cf4d3044988c0feb8 100644 (file)
@@ -41,6 +41,7 @@ unsigned exam_lsolve();
 unsigned exam_indexed();
 unsigned exam_color();
 unsigned exam_clifford();
+unsigned exam_archive();
 unsigned exam_misc();
 
 #endif // ndef EXAMS_H
index d44e9104deef214bedbba653c5e45c05fb107e08..86a9512d0c22aa67533637c00ecb7df1a540d790 100644 (file)
@@ -24,5 +24,7 @@
 (no output)
 ----------clifford objects:
 (no output)
+----------archiving system:
+(no output)
 ----------miscellaneous other things:
 (no output)