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 : wcschr_0100
23 * @tc.desc : returns a pointer to the first occurrence of the wide character c
24 * @tc.level : Level 0
25 */
wcschr_0100(void)26 void wcschr_0100(void)
27 {
28 wchar_t wcs[] = L"This is a c test for wcschr";
29 wchar_t *p;
30 p = wcschr(wcs, L'c');
31 if (*p != L'c') {
32 t_error("%s the character pointed to by the pointer is not c", __func__);
33 }
34 }
35
36 /**
37 * @tc.name : wcschr_0200
38 * @tc.desc : The target character is empty, returns a pointer to the end of the wide string
39 * @tc.level : Level 1
40 */
wcschr_0200(void)41 void wcschr_0200(void)
42 {
43 wchar_t wcs[] = L"This is a c test for wcschr";
44 wchar_t *p;
45 p = wcschr(wcs, L'\0');
46 if ((p - wcs) != wcslen(wcs)) {
47 t_error("%s pointer does not point to end of wide string", __func__);
48 }
49 }
50
51 /**
52 * @tc.name : wcschr_0300
53 * @tc.desc : The first character of the wide string is the target character
54 * @tc.level : Level 1
55 */
wcschr_0300(void)56 void wcschr_0300(void)
57 {
58 wchar_t wcs[] = L"This is a c test for wcschr";
59 wchar_t *p;
60 p = wcschr(wcs, L'T');
61 if (*p != L'T') {
62 t_error("%s the character pointed to by the pointer is not T", __func__);
63 }
64 }
65
main(int argc,char * argv[])66 int main(int argc, char *argv[])
67 {
68 wcschr_0100();
69 wcschr_0200();
70 wcschr_0300();
71 return t_status;
72 }