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.

33 lines
898 B

25 years ago
  1. #include "test_I.h"
  2. int test_I_logtest (int iterations)
  3. {
  4. int error = 0;
  5. int i;
  6. // Check commutativity.
  7. for (i = iterations; i > 0; i--) {
  8. cl_I a = testrandom_I();
  9. cl_I b = testrandom_I();
  10. ASSERT2(logtest(a,b) == logtest(b,a), a,b);
  11. }
  12. // Check some axioms.
  13. for (i = iterations; i > 0; i--) {
  14. cl_I a = testrandom_I();
  15. cl_I b = testrandom_I();
  16. ASSERT2(!logtest(a,logand(b,lognot(a))), a,b);
  17. ASSERT2(!logtest(logand(b,lognot(a)),a), a,b);
  18. ASSERT2(!logtest(b,logand(a,lognot(b))), a,b);
  19. ASSERT2(!logtest(logand(a,lognot(b)),b), a,b);
  20. if (a != 0)
  21. ASSERT2(logtest(a,logior(a,b)), a,b);
  22. if (b != 0)
  23. ASSERT2(logtest(b,logior(a,b)), a,b);
  24. }
  25. // Check some special cases, against ash and logbitp.
  26. for (i = iterations; i > 0; i--) {
  27. uintL a = random32() % 1024;
  28. cl_I b = testrandom_I();
  29. ASSERT2(logbitp(a,b) == logtest(b,ash(1,(sintL)a)), a,b);
  30. }
  31. return error;
  32. }