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 <wchar.h>
17#include <stdio.h>
18#include <string.h>
19#include "test.h"
20
21/**
22 * @tc.name      : wcsncasecmp_l_0100
23 * @tc.desc      : Test wcsncasecmp_l ignore case compares the first n digits of two wide strings
24 * @tc.level     : Level 0
25 */
26void wcsncasecmp_l_0100(void)
27{
28    int result = wcsncasecmp_l(L"hello1", L"HELLO2", 5, NULL);
29    if (result != 0) {
30        t_error("%s wcsncasecmp_l get result is %d are not want 0\n", __func__, result);
31    }
32}
33
34/**
35 * @tc.name      : wcsncasecmp_l_0200
36 * @tc.desc      : Test that wcsncasecmp_l returns the result when ws1 is greater than ws2 in the dictionary
37 * @tc.level     : Level 1
38 */
39void wcsncasecmp_l_0200(void)
40{
41    int result = wcsncasecmp_l(L"hello1", L"HELLO2", 6, NULL);
42    if (result >= 0) {
43        t_error("%s wcsncasecmp_l get result is %d are not want less 0\n", __func__, result);
44    }
45}
46
47/**
48 * @tc.name      : wcsncasecmp_l_0300
49 * @tc.desc      : Test that wcsncasecmp_l returns the result when ws1 is less than ws2 in the dictionary
50 * @tc.level     : Level 1
51 */
52void wcsncasecmp_l_0300(void)
53{
54    int result = wcsncasecmp_l(L"hello2", L"HELLO1", 6, NULL);
55    if (result <= 0) {
56        t_error("%s wcsncasecmp_l get result is %d are not want gress 0\n", __func__, result);
57    }
58}
59
60/**
61 * @tc.name      : wcsncasecmp_l_0400
62 * @tc.desc      : Test that wcsncasecmp_l returns the result when ws1 is longer in the dictionary than ws2
63 * @tc.level     : Level 1
64 */
65void wcsncasecmp_l_0400(void)
66{
67    int result = wcsncasecmp_l(L"hello", L"HELL", 5, NULL);
68    if (result <= 0) {
69        t_error("%s wcsncasecmp_l get result is %d are not want gress 0\n", __func__, result);
70    }
71}
72
73/**
74 * @tc.name      : wcsncasecmp_l_0500
75 * @tc.desc      : wcsncasecmp_l returns result when test ws1 is shorter than ws2 in dictionary
76 * @tc.level     : Level 1
77 */
78void wcsncasecmp_l_0500(void)
79{
80    int result = wcsncasecmp_l(L"hell", L"HELLO", 5, NULL);
81    if (result >= 0) {
82        t_error("%s wcsncasecmp_l get result is %d are not want less 0\n", __func__, result);
83    }
84}
85
86/**
87 * @tc.name      : wcsncasecmp_l_0600
88 * @tc.desc      : Test the result returned by wcsncasecmp_l when the number of comparisons is 0
89 * @tc.level     : Level 2
90 */
91void wcsncasecmp_l_0600(void)
92{
93    int result = wcsncasecmp_l(L"foo", L"bar", 0, NULL);
94    if (result != 0) {
95        t_error("%s wcsncasecmp_l get result is %d are not want 0\n", __func__, result);
96    }
97}
98
99int main(int argc, char *argv[])
100{
101    wcsncasecmp_l_0100();
102    wcsncasecmp_l_0200();
103    wcsncasecmp_l_0300();
104    wcsncasecmp_l_0400();
105    wcsncasecmp_l_0500();
106    wcsncasecmp_l_0600();
107    return t_status;
108}