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: test.c |
8 | ** |
9 | ** Purpose: Test for CharNextA, ensures it returns the proper char for an |
10 | ** entire string |
11 | ** |
12 | ** |
13 | **=========================================================*/ |
14 | |
15 | #include <palsuite.h> |
16 | |
17 | int __cdecl main(int argc,char *argv[]) |
18 | { |
19 | |
20 | char * AnExampleString = "this is the string" ; |
21 | char * StringPointer = AnExampleString; |
22 | int count = 0; |
23 | |
24 | /* |
25 | * Initialize the PAL and return FAILURE if this fails |
26 | */ |
27 | |
28 | if(0 != (PAL_Initialize(argc, argv))) |
29 | { |
30 | return FAIL; |
31 | } |
32 | |
33 | /* Use CharNext to move through an entire string. Ensure the pointer that |
34 | is returned points to the correct character, by comparing it with |
35 | 'StringPointer' which isn't touched by CharNext. |
36 | */ |
37 | |
38 | while(*AnExampleString != '\0') |
39 | { |
40 | |
41 | /* Fail if any characters are different. This is comparing the |
42 | * addresses of both characters, not the characters themselves. |
43 | */ |
44 | |
45 | if(AnExampleString != &StringPointer[count]) |
46 | { |
47 | Fail("ERROR: %#x and %#x are different. These should be the same " |
48 | " address.\n" ,AnExampleString,&StringPointer[count]); |
49 | |
50 | |
51 | } |
52 | |
53 | AnExampleString = CharNextA(AnExampleString); |
54 | ++count; |
55 | } |
56 | |
57 | PAL_Terminate(); |
58 | return PASS; |
59 | } |
60 | |
61 | |
62 | |
63 | |