diff options
Diffstat (limited to 'src/pal/tests/palsuite/c_runtime/_rotr/test1')
3 files changed, 98 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/c_runtime/_rotr/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_rotr/test1/CMakeLists.txt new file mode 100644 index 0000000000..6a8c97a56b --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_rotr/test1/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test1.c +) + +add_executable(paltest_rotr_test1 + ${SOURCES} +) + +add_dependencies(paltest_rotr_test1 CoreClrPal) + +target_link_libraries(paltest_rotr_test1 + pthread + rt + m + CoreClrPal +) diff --git a/src/pal/tests/palsuite/c_runtime/_rotr/test1/test1.c b/src/pal/tests/palsuite/c_runtime/_rotr/test1/test1.c new file mode 100644 index 0000000000..2d65edba29 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_rotr/test1/test1.c @@ -0,0 +1,61 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*===================================================================== +** +** Source: test1.c (_rotr) +** +** Purpose: Tests the PAL implementation of the _rotr function. +** The _rotr function rotates the unsigned value. _rotr +** rotates the value right 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, 0x8000007f, 0xc000003f, 0xe000001f, + 0xf000000f, 0xf8000007, 0xfc000003, 0xfe000001}, + {0x0055, 0x8000002a, 0x40000015, 0xa000000a, + 0x50000005, 0xa8000002, 0x54000001, 0xaa000000}, + {0x0099, 0x8000004c, 0x40000026, 0x20000013, + 0x90000009, 0xc8000004, 0x64000002, 0x32000001}, + {0x0036, 0x001b, 0x8000000d, 0xc0000006, + 0x60000003, 0xb0000001, 0xd8000000, 0x6c000000}, + {0x008f, 0x80000047, 0xc0000023, 0xe0000011, + 0xf0000008, 0x78000004, 0x3c000002 ,0x1e000001}}; + + + 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 = _rotr(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/_rotr/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_rotr/test1/testinfo.dat new file mode 100644 index 0000000000..9e3c11ab91 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_rotr/test1/testinfo.dat @@ -0,0 +1,17 @@ +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# + +Version = 1.0 +Section = C Runtime +Function = _rtor +Name = Positive Test for _rotr +TYPE = DEFAULT +EXE1 = test1 +Description += Tests the PAL implementation of the _rotr function. += The _rotr function rotates the unsigned value. _rotr += rotates the value right and "wraps" bits rotated off += one end of value to the other end. += This test compares the result to a previously determined += value. |