summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/c_runtime/wcsrchr/test1/test1.c
blob: ae8765776e95f3d14919f0d50293ac80267301f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

/*============================================================================
**
** Source:  test1.c
**
** Purpose: 
** Tests to see that wcsrchr correctly returns a pointer to the last occurence 
** of a character in a a string.
**
**
**==========================================================================*/



#include <palsuite.h>

int __cdecl main(int argc, char *argv[])
{
    WCHAR str[] = {'f','o','o',' ','b','a','r',' ','b','a','z',0};
    WCHAR c = (WCHAR)' ';
    WCHAR c2 = (WCHAR)'$';
    WCHAR *ptr;
    
    if (PAL_Initialize(argc, argv))
    {
        return FAIL;
    }


    ptr = wcsrchr(str, c);
    if (ptr != str + 7)
    {
        Fail("ERROR: expected wcsrchr to return pointer to %p, got %p\n", 
            str + 7, ptr);
    }

    ptr = wcsrchr(str, c2);
    if (ptr != NULL)
    {
        Fail("ERROR: expected wcsrchr to return pointer to %p, got %p\n", 
            NULL, ptr);
    }

    PAL_Terminate();
    return PASS;
}