You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
825 B

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