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** Tests that wcspbrk returns a pointer to the first element in the first
11** string that matches a character in the second (or NULL).
12**
13**
14**==========================================================================*/
15
16#include <palsuite.h>
17
18int __cdecl main(int argc, char *argv[])
19{
20 WCHAR *string;
21 WCHAR *key1;
22 WCHAR *key2;
23 WCHAR key3[] = {0};
24 WCHAR *result;
25
26 if (PAL_Initialize(argc, argv))
27 {
28 return FAIL;
29 }
30
31 string = convert("foo bar baz bar");
32 key1 = convert("z ");
33 key2 = convert("Q");
34
35 result = wcspbrk(string, key1);
36 if (result != string + 3)
37 {
38 Fail("ERROR: Got incorrect result in scanning \"%s\" with the set \"%s\".\n"
39 "Expected to get pointer to %#p, got %#p\n", convertC(string),
40 convertC(key1), string + 3, result);
41 }
42
43 result = wcspbrk(string, key2);
44 if (result != NULL)
45 {
46 Fail("ERROR: Got incorrect result in scanning \"%s\" with the set \"%s\".\n"
47 "Expected to get pointer to %#p, got %#p\n", convertC(string),
48 convertC(key2), NULL, result);
49 }
50
51 result = wcspbrk(string, key3);
52 if (result != NULL)
53 {
54 Fail("ERROR: Got incorrect result in scanning \"%s\" with the set \"%s\".\n"
55 "Expected to get pointer to %#p, got %#p\n", convertC(string),
56 convertC(key3), NULL, result);
57 }
58
59 PAL_Terminate();
60 return PASS;
61}
62