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.

27 lines
584 B

25 years ago
  1. #include "test_I.h"
  2. int test_I_minus (int iterations)
  3. {
  4. int error = 0;
  5. int i;
  6. // Check anti-commutativity.
  7. for (i = iterations; i > 0; i--) {
  8. cl_I a = testrandom_I();
  9. cl_I b = testrandom_I();
  10. ASSERT2((a-b) + (b-a) == 0, a,b);
  11. }
  12. // Check associativity.
  13. for (i = iterations; i > 0; i--) {
  14. cl_I a = testrandom_I();
  15. cl_I b = testrandom_I();
  16. cl_I c = testrandom_I();
  17. ASSERT3(a-(b-c) == c-(b-a), a,b,c);
  18. }
  19. // Check special case 0.
  20. for (i = iterations; i > 0; i--) {
  21. cl_I a = testrandom_I();
  22. ASSERT1(a-0 == a, a);
  23. ASSERT1(0-(0-a) == a, a);
  24. }
  25. return error;
  26. }