blob: e345acce5b51043f974239385204aeac79e756e9 [file] [log] [blame]
Daniel Dunbarfd089992009-06-26 16:47:03 +00001//===-- modsi3_test.c - Test __modsi3 -------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file tests __modsi3 for the compiler_rt library.
11//
12//===----------------------------------------------------------------------===//
13
14#include "int_lib.h"
15#include <stdio.h>
16
17// Returns: a % b
18
19si_int __modsi3(si_int a, si_int b);
20
21int test__modsi3(si_int a, si_int b, si_int expected)
22{
23 si_int x = __modsi3(a, b);
24 if (x != expected)
25 printf("error in __modsi3: %d %% %d = %d, expected %d\n",
26 a, b, x, expected);
27 return x != expected;
28}
29
30int main()
31{
32 if (test__modsi3(0, 1, 0))
33 return 1;
34 if (test__modsi3(0, -1, 0))
35 return 1;
36
37 if (test__modsi3(5, 3, 2))
38 return 1;
39 if (test__modsi3(5, -3, 2))
40 return 1;
41 if (test__modsi3(-5, 3, -2))
42 return 1;
43 if (test__modsi3(-5, -3, -2))
44 return 1;
45
46 if (test__modsi3(0x80000000, 1, 0x0))
47 return 1;
48 if (test__modsi3(0x80000000, 2, 0x0))
49 return 1;
50 if (test__modsi3(0x80000000, -2, 0x0))
51 return 1;
52 if (test__modsi3(0x80000000, 3, -2))
53 return 1;
54 if (test__modsi3(0x80000000, -3, -2))
55 return 1;
56
57 return 0;
58}