ddlog_test.c 685 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include <assert.h>
  2. #include <stdint.h>
  3. #include <stdio.h>
  4. #include <strings.h>
  5. #include "ddlog.h"
  6. #include "entropy.h"
  7. #include "group.h"
  8. #include "timeit.h"
  9. #ifdef NDEBUG
  10. #error "running test without debug?"
  11. #endif
  12. int main()
  13. {
  14. group_init();
  15. dlog_precompute();
  16. mpz_entropy_init();
  17. for (int i=0; i < (int) (1e2); i++) {
  18. mpz_t n, n0;
  19. mpz_inits(n, n0, NULL);
  20. mpz_urandomm(n0, _rstate, p);
  21. mpz_set(n, n0);
  22. uint32_t expected = convert_naif(n);
  23. mpz_set(n, n0);
  24. uint32_t converted = convert(n->_mp_d);
  25. printf("%d %d\n", converted, expected);
  26. assert(converted == expected);
  27. mpz_clears(n, n0, NULL);
  28. }
  29. group_clear();
  30. return 0;
  31. }