1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5/*=====================================================================
6**
7** Source: abs.c (test 1)
8**
9** Purpose: Tests the PAL implementation of the abs function.
10**
11**
12**===================================================================*/
13
14#include <palsuite.h>
15
16struct TESTS
17{
18 int nTest;
19 int nResult;
20};
21
22int __cdecl main(int argc, char *argv[])
23{
24 int i = 0;
25 int nRc = 0;
26 struct TESTS testCase[] =
27 {
28 {0, 0},
29 {1, 1},
30 {-1, 1}
31 };
32
33
34 if (0 != PAL_Initialize(argc,argv))
35 {
36 return FAIL;
37 }
38
39 for (i = 0; i < (sizeof(testCase)/sizeof(struct TESTS)); i++)
40 {
41 nRc = abs(testCase[i].nTest);
42 if (nRc != testCase[i].nResult)
43 {
44 Fail("abs: ERROR -> abs(%d) returned %d "
45 "when it was expected to return %d \n",
46 testCase[i].nTest,
47 nRc,
48 testCase[i].nResult);
49 }
50 }
51
52 PAL_Terminate();
53 return PASS;
54}
55