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.

35 lines
716 B

7 years ago
​
​
​
​
​
​
​
​
​
7 years ago
7 years ago
​
​
7 years ago
​
7 years ago
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
  1. /* $Id: testcodelength.c,v 1.3 2012/05/02 10:30:26 nanard Exp $ */
  2. /* Project : miniupnp
  3. * Author : Thomas BERNARD
  4. * copyright (c) 2005-2008 Thomas Bernard
  5. * This software is subjet to the conditions detailed in the
  6. * provided LICENCE file. */
  7. #include "codelength.h"
  8. #include <stdio.h>
  9. int main(int argc, char ** argv)
  10. {
  11. unsigned char buf[256];
  12. unsigned char * p;
  13. long i, j;
  14. (void) argc;
  15. (void) argv;
  16. for (i = 1; i < 1000000000; i *= 2)
  17. {
  18. /* encode i, decode to j */
  19. printf("%ld ", i);
  20. p = buf;
  21. CODELENGTH(i, p);
  22. p = buf;
  23. DECODELENGTH(j, p);
  24. if (i != j)
  25. {
  26. fprintf(stderr, "Error ! encoded %ld, decoded %ld.\n", i, j);
  27. return 1;
  28. }
  29. }
  30. printf("Test succesful\n");
  31. return 0;
  32. }