1 //===-- absvsi2_test.c - Test __absvsi2 -----------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file tests __absvsi2 for the compiler_rt library.
12 //===----------------------------------------------------------------------===//
18 // Returns: absolute value
20 // Effects: aborts if abs(x) < 0
22 si_int
__absvsi2(si_int a
);
24 int test__absvsi2(si_int a
)
26 si_int x
= __absvsi2(a
);
30 if (x
!= expected
|| expected
< 0)
31 printf("error in __absvsi2(0x%X) = %d, expected positive %d\n",
38 // if (test__absvsi2(0x80000000)) // should abort
40 if (test__absvsi2(0x00000000))
42 if (test__absvsi2(0x00000001))
44 if (test__absvsi2(0x00000002))
46 if (test__absvsi2(0x7FFFFFFE))
48 if (test__absvsi2(0x7FFFFFFF))
50 if (test__absvsi2(0x80000001))
52 if (test__absvsi2(0x80000002))
54 if (test__absvsi2(0xFFFFFFFE))
56 if (test__absvsi2(0xFFFFFFFF))
60 for (i
= 0; i
< 10000; ++i
)
61 if (test__absvsi2(rand()))