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