[msvc] Update csproj files
[mono.git] / eglib / test / endian.c
1 #include "test.h"
2
3 RESULT
4 test_swap ()
5 {
6         guint32 a = 0xabcdef01, res32;
7         guint64 b = (((guint64)a) << 32) | a, res64;
8         guint64 b_expect = (((guint64)0x1efcdab) << 32) | 0x01efcdab;
9         guint16 c = 0xabcd, res16;
10         
11         res32 = GUINT32_SWAP_LE_BE (a);
12         if (res32 != 0x01efcdab)
13                 return FAILED ("GUINT32_SWAP_LE_BE returned 0x%x", res32);
14         res32 = GUINT32_SWAP_LE_BE (1);
15         if (res32 != 0x1000000)
16                 return FAILED ("GUINT32_SWAP_LE_BE returned 0x%x", res32);
17
18         res64 = GUINT64_SWAP_LE_BE(b);
19         if (res64 != b_expect)
20                 return FAILED ("GUINT64_SWAP_LE_BE returned 0x%llx (had=0x%llx)", res64, b);
21         res16 = GUINT16_SWAP_LE_BE(c);
22         if (res16 != 0xcdab)
23                 return FAILED ("GUINT16_SWAP_LE_BE returned 0x%x", (guint32) res16);    
24         
25         return OK;
26 }
27
28 /*
29  * test initialization
30  */
31
32 static Test endian_tests [] = {
33         {"swap", test_swap},
34         {NULL, NULL}
35 };
36
37 DEFINE_TEST_GROUP_INIT(endian_tests_init, endian_tests)
38