summaryrefslogtreecommitdiff
path: root/test/builtins/Unit/truncdfsf2vfp_test.c
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2014-02-14 09:47:31 +0000
committerAlexey Samsonov <samsonov@google.com>2014-02-14 09:47:31 +0000
commit28d10da69f52af1b01fbc12fd503621713641500 (patch)
tree76222f9698fdaafdfe23235d18d5ac804ea515d6 /test/builtins/Unit/truncdfsf2vfp_test.c
parent08c9d0bc3ac37d7d5def0318a1420e67cca53e41 (diff)
Move tests for BlocksRuntime and builtins to corresponding directories under test/
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@201396 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/builtins/Unit/truncdfsf2vfp_test.c')
-rw-r--r--test/builtins/Unit/truncdfsf2vfp_test.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/builtins/Unit/truncdfsf2vfp_test.c b/test/builtins/Unit/truncdfsf2vfp_test.c
new file mode 100644
index 000000000..afc7868b0
--- /dev/null
+++ b/test/builtins/Unit/truncdfsf2vfp_test.c
@@ -0,0 +1,50 @@
+//===-- truncdfsf2vfp_test.c - Test __truncdfsf2vfp -----------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __truncdfsf2vfp for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+extern float __truncdfsf2vfp(double a);
+
+#if __arm__
+int test__truncdfsf2vfp(double a)
+{
+ float actual = __truncdfsf2vfp(a);
+ float expected = a;
+ if (actual != expected)
+ printf("error in test__truncdfsf2vfp(%f) = %f, expected %f\n",
+ a, actual, expected);
+ return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+ if (test__truncdfsf2vfp(0.0))
+ return 1;
+ if (test__truncdfsf2vfp(1.0))
+ return 1;
+ if (test__truncdfsf2vfp(-1.0))
+ return 1;
+ if (test__truncdfsf2vfp(3.1415926535))
+ return 1;
+ if (test__truncdfsf2vfp(123.456))
+ return 1;
+#else
+ printf("skipped\n");
+#endif
+ return 0;
+}