2
* This testing program makes sure the byteswap functions work
4
* Copyright (C) 2000 by Theodore Ts'o.
7
* This file may be redistributed under the terms of the GNU Public
20
#include <sys/types.h>
38
0x00000001, 0x01000000,
39
0x80000000, 0x00000080,
40
0x12345678, 0x78563412,
41
0xffff0000, 0x0000ffff,
42
0x00ff0000, 0x0000ff00,
43
0xff000000, 0x000000ff,
44
0x00000000, 0x00000000
47
int main(int argc, char **argv)
52
printf("Testing ext2fs_swab16\n");
55
printf("swab16(0x%04x) = 0x%04x\n", test1[i],
56
ext2fs_swab16(test1[i]));
57
if (ext2fs_swab16(test1[i]) != test1[i+1]) {
58
printf("Error!!! %04x != %04x\n",
59
ext2fs_swab16(test1[i]), test1[i+1]);
62
if (ext2fs_swab16(test1[i+1]) != test1[i]) {
63
printf("Error!!! %04x != %04x\n",
64
ext2fs_swab16(test1[i+1]), test1[i]);
68
} while (test1[i] != 0);
70
printf("Testing ext2fs_swab32\n");
73
printf("swab32(0x%08x) = 0x%08x\n", test2[i],
74
ext2fs_swab32(test2[i]));
75
if (ext2fs_swab32(test2[i]) != test2[i+1]) {
76
printf("Error!!! %04x != %04x\n",
77
ext2fs_swab32(test2[i]), test2[i+1]);
80
if (ext2fs_swab32(test2[i+1]) != test2[i]) {
81
printf("Error!!! %04x != %04x\n",
82
ext2fs_swab32(test2[i+1]), test2[i]);
86
} while (test2[i] != 0);
89
printf("No errors found in the byteswap implementation!\n");