blob: 5eca990a08e4cead12f7c5f21123731c47606ced [file] [log] [blame]
Harald Welte712691d2011-09-01 14:47:31 +02001
2#include <stdio.h>
3#include <stdlib.h>
4#include <stdint.h>
5#include <string.h>
6
7#include <osmocom/core/utils.h>
8#include <osmocom/core/bits.h>
9
10static const uint8_t input[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
11static const uint8_t exp_out[] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
12
13int main(int argc, char **argv)
14{
15 uint8_t out[ARRAY_SIZE(input)];
16 unsigned int offs;
17
18 for (offs = 0; offs < sizeof(out); offs++) {
19 uint8_t *start = out + offs;
20 uint8_t len = sizeof(out) - offs;
21
22 memcpy(out, input, sizeof(out));
23
24 printf("INORDER: %s\n", osmo_hexdump(start, len));
25 osmo_revbytebits_buf(start, len);
26 printf("REVERSED: %s\n", osmo_hexdump(start, len));
27 if (memcmp(start, exp_out + offs, len)) {
28 printf("EXPECTED: %s\n", osmo_hexdump(exp_out+offs, len));
29 fprintf(stderr, "REVERSED != EXPECTED!\n");
30 exit(1);
31 }
32 printf("\n");
33 }
34
35 return 0;
36}