File: testcodelength.c

package info (click to toggle)
minissdpd 1.5.20190210-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 484 kB
  • sloc: ansic: 4,944; sh: 296; makefile: 99
file content (31 lines) | stat: -rw-r--r-- 707 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* $Id: testcodelength.c,v 1.4 2018/02/03 22:16:58 nanard Exp $ */
/* Project : miniupnp
 * Author : Thomas BERNARD
 * copyright (c) 2005-2018 Thomas Bernard
 * This software is subjet to the conditions detailed in the
 * provided LICENCE file. */
#include <stdio.h>
#include "codelength.h"

int main(int argc, char * * argv)
{
	unsigned char buf[256];
	unsigned char * p;
	long i, j;
	(void)argc; (void)argv;

	for(i = 1; i < 1000000000; i *= 2) {
		/* encode i, decode to j */
		printf("%ld ", i);
		p = buf;
		CODELENGTH(i, p);
		p = buf;
		DECODELENGTH(j, p);
		if(i != j) {
			fprintf(stderr, "Error ! encoded %ld, decoded %ld.\n", i, j);
			return 1;
		}
	}
	printf("Test successful\n");
	return 0;
}