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 | ** Search a string for a given character. Search for a character contained |
11 | ** in the string, and ensure the pointer returned points to it. Then search |
12 | ** for the null character, and ensure the pointer points to that. Finally |
13 | ** search for a character which is not in the string and ensure that it |
14 | ** returns NULL. |
15 | ** |
16 | ** |
17 | **==========================================================================*/ |
18 | |
19 | #include <palsuite.h> |
20 | |
21 | |
22 | int __cdecl main(int argc, char *argv[]) |
23 | { |
24 | char *str = "foo bar baz" ; |
25 | char *ptr; |
26 | |
27 | |
28 | if (PAL_Initialize(argc, argv)) |
29 | { |
30 | return FAIL; |
31 | } |
32 | |
33 | |
34 | ptr = strrchr(str, 'b'); |
35 | if (ptr != str + 8) |
36 | { |
37 | Fail("Expected strrchr() to return %p, got %p!\n" , str + 8, ptr); |
38 | } |
39 | |
40 | ptr = strrchr(str, 0); |
41 | if (ptr != str + 11) |
42 | { |
43 | Fail("Expected strrchr() to return %p, got %p!\n" , str + 11, ptr); |
44 | } |
45 | |
46 | ptr = strrchr(str, 'x'); |
47 | if (ptr != NULL) |
48 | { |
49 | Fail("Expected strrchr() to return NULL, got %p!\n" , ptr); |
50 | } |
51 | |
52 | PAL_Terminate(); |
53 | |
54 | return PASS; |
55 | } |
56 | |