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.

31 lines
706 B

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 <stdio.h>
  8. #include "codelength.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; (void)argv;
  15. for(i = 1; i < 1000000000; i *= 2) {
  16. /* encode i, decode to j */
  17. printf("%ld ", i);
  18. p = buf;
  19. CODELENGTH(i, p);
  20. p = buf;
  21. DECODELENGTH(j, p);
  22. if(i != j) {
  23. fprintf(stderr, "Error ! encoded %ld, decoded %ld.\n", i, j);
  24. return 1;
  25. }
  26. }
  27. printf("Test succesful\n");
  28. return 0;
  29. }