1 #include "test_I.h" 2 #include <cln/input.h> 3 #include <sstream> 4 test_I_io(int iterations)5int 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 unsigned 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 return error; 29 } 30