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 Library
8 * General Public License, version 2.
21 #include <sys/types.h>
39 0x00000001, 0x01000000,
40 0x80000000, 0x00000080,
41 0x12345678, 0x78563412,
42 0xffff0000, 0x0000ffff,
43 0x00ff0000, 0x0000ff00,
44 0xff000000, 0x000000ff,
45 0x00000000, 0x00000000
48 int main(int argc, char **argv)
53 printf("Testing ext2fs_swab16\n");
56 printf("swab16(0x%04x) = 0x%04x\n", test1[i],
57 ext2fs_swab16(test1[i]));
58 if (ext2fs_swab16(test1[i]) != test1[i+1]) {
59 printf("Error!!! %04x != %04x\n",
60 ext2fs_swab16(test1[i]), test1[i+1]);
63 if (ext2fs_swab16(test1[i+1]) != test1[i]) {
64 printf("Error!!! %04x != %04x\n",
65 ext2fs_swab16(test1[i+1]), test1[i]);
69 } while (test1[i] != 0);
71 printf("Testing ext2fs_swab32\n");
74 printf("swab32(0x%08x) = 0x%08x\n", test2[i],
75 ext2fs_swab32(test2[i]));
76 if (ext2fs_swab32(test2[i]) != test2[i+1]) {
77 printf("Error!!! %04x != %04x\n",
78 ext2fs_swab32(test2[i]), test2[i+1]);
81 if (ext2fs_swab32(test2[i+1]) != test2[i]) {
82 printf("Error!!! %04x != %04x\n",
83 ext2fs_swab32(test2[i+1]), test2[i]);
87 } while (test2[i] != 0);
90 printf("No errors found in the byteswap implementation!\n");