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