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.

32 lines
543 B

25 years ago
  1. #include "test_I.h"
  2. int test_I_integer_length (int iterations)
  3. {
  4. int error = 0;
  5. int i;
  6. // Check against ash.
  7. for (i = iterations; i > 0; i--) {
  8. cl_I a = testrandom_I();
  9. uintL l = integer_length(a);
  10. if (a >= 0) {
  11. int b = 0;
  12. if (a < ash(1,l)) {
  13. if (a == 0)
  14. b = (l == 0);
  15. else
  16. b = (l > 0 && a >= ash(1,l-1));
  17. }
  18. ASSERT1(b, a);
  19. } else {
  20. int b = 0;
  21. if (a >= ash(-1,l)) {
  22. if (a == -1)
  23. b = (l == 0);
  24. else
  25. b = (l > 0 && a < ash(-1,l-1));
  26. }
  27. ASSERT1(b, a);
  28. }
  29. }
  30. return error;
  31. }