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: test1.c
8**
9** Purpose:
10** Compare a number of different strings against each other, ensure that the
11** three return values are given at the appropriate times.
12**
13**
14**==========================================================================*/
15
16#include <palsuite.h>
17
18typedef struct
19{
20 int result;
21 char string1[50];
22 char string2[50];
23} testCase;
24
25testCase testCases[]=
26{
27 {0,"Hello","Hello"},
28 {1,"hello","Hello"},
29 {-1,"Hello","hello"},
30 {0,"0Test","0Test"},
31 {0,"***???","***???"},
32 {0,"Testing the string for string comparison","Testing the string for "
33 "string comparison"},
34 {-1,"Testing the string for string comparison","Testing the string for "
35 "string comparsioa"},
36 {1,"Testing the string for string comparison","Testing the string for "
37 "comparison"},
38 {-1,"aaaabbbbb","aabcdefeccg"}
39};
40
41int __cdecl main(int argc, char *argv[])
42{
43 int i = 0;
44 int result = 0;
45
46 /*
47 * Initialize the PAL
48 */
49 if (0 != PAL_Initialize(argc, argv))
50 {
51 return FAIL;
52 }
53
54 /* Loop through structure and test each case */
55 for (i=0; i < sizeof(testCases)/sizeof(testCase); i++)
56 {
57 result = strcmp(testCases[i].string1,testCases[i].string2);
58
59 /* Compare returned value */
60 if( ((result == 0) && (testCases[i].result !=0)) ||
61 ((result <0) && (testCases[i].result !=-1)) ||
62 ((result >0) && (testCases[i].result !=1)) )
63 {
64 Fail("ERROR: strcmp returned %d instead of %d\n",
65 result, testCases[i].result);
66 }
67
68 }
69
70 PAL_Terminate();
71
72 return PASS;
73}
74