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 <libintl.h>
17 #include <stdio.h>
18 #include <locale.h>
19 #include "functionalext.h"
20
21 #define PACKAGE "test_dcngettext"
22
23 /**
24 * @tc.name : dgettext_0200
25 * @tc.desc : Get string from dgettext() with mo file and specified domain
26 * This case needs to push the test_dgettext.mo file of the current path to the remote board.
27 * The remote path should be "${test_src_dir}/zh_CN/LC_MESSAGES/test_dgettext.mo"
28 * @tc.level : level 0
29 */
dgettext_0100()30 void dgettext_0100()
31 {
32 char *msgid = "hello";
33 setlocale(LC_ALL, "zh_CN");
34 bindtextdomain(PACKAGE, "/data/local/tmp/");
35 char* result = dgettext(PACKAGE, msgid);
36 if (!result) {
37 EXPECT_PTRNE("dgettext_0200", result, NULL);
38 return;
39 }
40 EXPECT_TRUE("dgettext_0200", strlen(result) > 0);
41 EXPECT_STREQ("dgettext_0200", "nihao", result);
42 }
43
main(void)44 int main(void)
45 {
46 dgettext_0100();
47 return t_status;
48 }
49
50