summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/c_runtime/_rotl
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2016-11-23 19:09:09 +0900
committerJiyoung Yun <jy910.yun@samsung.com>2016-11-23 19:09:09 +0900
commit4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (patch)
tree98110734c91668dfdbb126fcc0e15ddbd93738ca /src/pal/tests/palsuite/c_runtime/_rotl
parentfa45f57ed55137c75ac870356a1b8f76c84b229c (diff)
downloadcoreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.gz
coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.bz2
coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.zip
Imported Upstream version 1.1.0upstream/1.1.0
Diffstat (limited to 'src/pal/tests/palsuite/c_runtime/_rotl')
-rw-r--r--src/pal/tests/palsuite/c_runtime/_rotl/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/c_runtime/_rotl/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/_rotl/test1/test1.cpp55
-rw-r--r--src/pal/tests/palsuite/c_runtime/_rotl/test1/testinfo.dat17
4 files changed, 95 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/c_runtime/_rotl/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_rotl/CMakeLists.txt
new file mode 100644
index 0000000000..f6aa0cb2d9
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/_rotl/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+
diff --git a/src/pal/tests/palsuite/c_runtime/_rotl/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_rotl/test1/CMakeLists.txt
new file mode 100644
index 0000000000..bafaa23732
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/_rotl/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test1.cpp
+)
+
+add_executable(paltest_rotl_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_rotl_test1 coreclrpal)
+
+target_link_libraries(paltest_rotl_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/_rotl/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_rotl/test1/test1.cpp
new file mode 100644
index 0000000000..3a31388893
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/_rotl/test1/test1.cpp
@@ -0,0 +1,55 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/*=====================================================================
+**
+** Source: test1.c (_rotl)
+**
+** Purpose: Tests the PAL implementation of the _rotl function.
+** The _rotl function rotates the unsigned value. _rotl
+** rotates the value left and "wraps" bits rotated off
+** one end of value to the other end.
+** This test compares the result to a previously determined
+** value.
+**
+**
+**
+**===================================================================*/
+#include <palsuite.h>
+
+int __cdecl main(int argc, char **argv)
+{
+ unsigned results = 0;
+ int i,j;
+
+ unsigned hTestNums[5][8] = {
+ {0x00ff, 0x01fe, 0x03fc, 0x07f8, 0x0ff0, 0x1fe0, 0x3fc0, 0x7f80},
+ {0x0055, 0x00aa, 0x0154, 0x02a8, 0x0550, 0x0aa0, 0x1540, 0x2a80},
+ {0x0099, 0x0132, 0x0264, 0x04c8, 0x0990, 0x1320, 0x2640, 0x4c80},
+ {0x0036, 0x006c, 0x00d8, 0x01b0, 0x0360, 0x06c0, 0x0d80, 0x1b00},
+ {0x008f, 0x011e, 0x023c, 0x0478, 0x08f0, 0x11e0, 0x23c0, 0x4780}};
+
+ if ((PAL_Initialize(argc, argv)) != 0)
+ {
+ return (FAIL);
+ }
+
+ /*Loop through expected test results*/
+ for (j = 0; j <= 4; j++)
+ {
+ for(i = 1; i <= 7; i++)
+ {
+ results = _rotl(hTestNums[j][0], i);
+ if (results != hTestNums[j][i])
+ {
+ Fail("ERROR: \"0x%4.4x\" rotated bits to the left %d times"
+ " gave \"0x%4.4x\", expected \"0x%4.4x\"\n",
+ hTestNums[j][0], i, results, hTestNums[j][i]) ;
+ }
+ }
+ }
+
+ PAL_Terminate();
+ return (PASS);
+}
diff --git a/src/pal/tests/palsuite/c_runtime/_rotl/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_rotl/test1/testinfo.dat
new file mode 100644
index 0000000000..9c87473f8e
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/_rotl/test1/testinfo.dat
@@ -0,0 +1,17 @@
+# Licensed to the .NET Foundation under one or more agreements.
+# The .NET Foundation licenses this file to you under the MIT license.
+# See the LICENSE file in the project root for more information.
+
+Version = 1.0
+Section = C Runtime
+Function = _rtol
+Name = Positive Test for _rotl
+TYPE = DEFAULT
+EXE1 = test1
+Description
+= Tests the PAL implementation of the _rotl function.
+= The _rotl function rotates the unsigned value. _rotl
+= rotates the value left and "wraps" bits rotated off
+= one end of value to the other end.
+= This test compares the result to a previously determined
+= value.