1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#include <stdio.h>
17#include <string.h>
18#include <wchar.h>
19#include "test.h"
20
21/**
22 * @tc.name      : wmemchr_0100
23 * @tc.desc      : Find the first occurrence of a wide character in the target array
24 * @tc.level     : Level 0
25 */
26void wmemchr_0100(void)
27{
28    wchar_t str[] = L"ABCDEFG";
29    wchar_t target = L'C';
30    size_t sz = sizeof(str) / sizeof(*str);
31    wchar_t *result = wmemchr(str, target, sz);
32    if (!result) {
33        t_error("%s not found target ch\n", __func__);
34    }
35}
36
37/**
38 * @tc.name      : wmemchr_0200
39 * @tc.desc      : Test the return value of the function when there are no wide characters in the destination array
40 * @tc.level     : Level 1
41 */
42void wmemchr_0200(void)
43{
44    wchar_t str[] = L"ABCDEFG";
45    wchar_t target = L'H';
46    size_t sz = sizeof(str) / sizeof(*str);
47    wchar_t *result = wmemchr(str, target, sz);
48    if (result) {
49        t_error("%s found target ch\n", __func__);
50    }
51}
52
53/**
54 * @tc.name      : wmemchr_0300
55 * @tc.desc      : Test the return value of the function when n=0
56 * @tc.level     : Level 1
57 */
58void wmemchr_0300(void)
59{
60    wchar_t str[] = L"ABCDEFG";
61    wchar_t target = L'C';
62    size_t sz = 0;
63    wchar_t *result = wmemchr(str, target, sz);
64    if (result) {
65        t_error("%s found target ch", __func__);
66    }
67}
68
69int main(int argc, char *argv[])
70{
71    wmemchr_0100();
72    wmemchr_0200();
73    wmemchr_0300();
74    return t_status;
75}