]> www.ginac.de Git - cln.git/blob - tests/test_I_io.cc
Fix double_approx(const cl_RA& x) on 64-Bit platforms.
[cln.git] / tests / test_I_io.cc
1 #include "test_I.h"
2 #include <cln/input.h>
3 #include <sstream>
4
5 int test_I_io (int iterations)
6 {
7         int error = 0;
8         for (int i = iterations; i > 0; i--) {
9                 cl_I a = testrandom_I();
10                 int base = iterations % (36-1) + 2;
11                 cl_read_flags rflags = {syntax_integer, lsyntax_standard, base};
12                 stringstream buf;
13                 print_integer(buf, base, a);
14                 cl_I b;
15                 try {
16                         b = read_integer(buf, rflags);
17                         ASSERT1(a == b, a);
18                 } catch (runtime_exception& err) {
19                         std::cerr << "Got an error while parsing \"" 
20                                 << buf.str() << "\" with base = " << base
21                                 << " (in decimal: " << a << ")" << std::endl;
22                         std::cerr << "Details: " << err.what() << std::endl;
23                         ++error;
24                         break;
25                 }
26
27         }
28 #if defined(_WIN32)
29         std::cerr << "[The test is known to fail on this platform, ignore it]" << std::endl;
30         return 0;
31 #else
32         return error;
33 #endif
34 }