提交 b7127c23 编写于 作者: G ganlan

add libctest cases

Signed-off-by: Nganlan <tony.gan@huawei.com>
上级 078c7a12
......@@ -27,6 +27,7 @@
#define EPS (0.00001)
#define CMPFLAG 0
#define ERREXPECT (-1)
#define ONREXPECT 1
#define EXPECT_TRUE(fun, c) do { \
if (!(c)) \
......@@ -43,6 +44,16 @@
t_error("[%s] failed %d != %d \n", fun, a, b); \
} while (0)
#define EXPECT_LT(fun, a, b) do { \
if ((a) >= (b)) \
t_error("[%s] failed (errno: %s) %d >= %d \n", #fun, strerror(errno), a, b); \
} while(0)
#define EXPECT_MT(fun, a, b) do { \
if ((a) <= (b)) \
t_error("[%s] failed (errno: %s) %d >= %d \n", #fun, strerror(errno), a, b); \
} while(0)
#define EXPECT_NE(fun, a, b) do { \
if ((int)(a) == (int)(b)) \
t_error("[%s] failed %d == %d \n", fun, (a), (b)); \
......@@ -54,9 +65,14 @@
t_error("[%s] failed %s != %s \n", fun, (a), (b)); \
} while (0)
#define EXPECT_STRNE(fun, a, b) do { \
if (strcmp((a), (b)) == 0) \
t_error("[%s] failed %s == %s \n", fun, (a), (b)); \
#define EXPECT_STRLT(fun, a, b) do { \
if ((a) >= (b)) \
t_error("[%s] failed (errno: %s) %d >= %d \n", #fun, strerror(errno), a, b); \
} while(0)
#define EXPECT_STRMT(fun, a, b) do { \
if ((a) <= (b)) \
t_error("[%s] failed (errno: %s) %d >= %d \n", #fun, strerror(errno), a, b); \
} while(0)
/* floating point comparison */
......@@ -77,5 +93,25 @@
} \
} while (0)
#define EXPECT_STRNE(fun, a, b) do { \
if (strcmp((a), (b)) == 0) \
t_error("[%s] failed %s == %s \n", fun, (a), (b)); \
} while(0)
#define EXPECT_LONGEQ(fun, a, b) do { \
if ((long)(a) != (long)(b)) \
t_error("[%s] failed %ld != %ld \n", fun, a, b); \
} while(0)
#define EXPECT_LONGLONGEQ(fun, a, b) do { \
if ((long)(a) != (long)(b)) \
t_error("[%s] failed %lld != %lld \n", fun, a, b); \
} while(0)
#define EXPECT_GT(fun, a, b) do { \
if ((a) <= (b)) { \
t_error("[%s] failed %d > %d \n", fun, a, b); \
} \
} while(0)
#endif
\ No newline at end of file
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("../../../test_template.gni")
import("test_src_functionalext_supplement.gni")
group("functionalext_supplement_test") {
testonly = true
deps = []
foreach(s, functionalext_supplement_list) {
deps += [ "${s}" ]
}
}
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("../../../../test_template.gni")
import("test_src_functionalext_supplement_conf.gni")
foreach(s, functionalext_supplement_conf_test) {
test_unittest(s) {
target_dir = "functionalext/supplement/conf"
}
}
group("functionalext_supplement_conf_test") {
testonly = true
deps = []
foreach(s, functionalext_supplement_conf_test) {
deps += [ ":${s}" ]
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "functionalext.h"
/**
* @tc.name : fpathconf_0100
* @tc.desc : Verify that you can query values related to file system limits and options
* (each parameter is valid, the name parameter is _PC_LINK_MAX,)
* @tc.level : Level 0
*/
void fpathconf_0100(void)
{
long result;
result = fpathconf(0, _PC_LINK_MAX);
EXPECT_EQ("fpathconf_0100", result, _POSIX_LINK_MAX);
}
/**
* @tc.name : fpathconf_0200
* @tc.desc : Verify that you can query values related to file system limits and options
* (each parameter is valid, the name parameter is _PC_SOCK_MAXBUF,)
* @tc.level : Level 0
*/
void fpathconf_0200(void)
{
long result;
result = fpathconf(0, _PC_SOCK_MAXBUF);
EXPECT_EQ("fpathconf_0200", result, -1);
}
/**
* @tc.name : fpathconf_0300
* @tc.desc : Verify that you can query values related to file system limits and options
* (each parameter is valid, the name parameter is _PC_FILESIZEBITS,)
* @tc.level : Level 0
*/
void fpathconf_0300(void)
{
long result;
result = fpathconf(0, _PC_FILESIZEBITS);
EXPECT_EQ("fpathconf_0300", result, FILESIZEBITS);
}
/**
* @tc.name : fpathconf_0400
* @tc.desc : Verify that you can query values related to file system limits and options
* (each parameter is valid, the name parameter is _PC_2_SYMLINKS,)
* @tc.level : Level 0
*/
void fpathconf_0400(void)
{
long result;
result = fpathconf(0, _PC_2_SYMLINKS);
EXPECT_EQ("fpathconf_0400", result, 1);
}
/**
* @tc.name : fpathconf_0500
* @tc.desc : Verify that you can query values related to file system limits and options
* (each parameter is valid, the name parameter is 1000,)
* @tc.level : Level 2
*/
void fpathconf_0500(void)
{
long result;
result = fpathconf(0, 1000);
EXPECT_EQ("fpathconf_0500", result, -1);
}
int main()
{
fpathconf_0100();
fpathconf_0200();
fpathconf_0300();
fpathconf_0400();
fpathconf_0500();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <sys/sysinfo.h>
#include "functionalext.h"
typedef void (*TEST_FUN)();
/**
* @tc.name : get_nprocs_0100
* @tc.desc : Verify the total number of pages available for acquisition
* @tc.level : Level 0
*/
void get_nprocs_0100(void)
{
int result;
result = get_avphys_pages();
bool flag = false;
if (result > 0) {
flag = true;
}
EXPECT_TRUE("fpathconf_0100", true);
}
TEST_FUN G_Fun_Array[] = {
get_nprocs_0100,
};
int main()
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
G_Fun_Array[pos]();
}
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <sys/sysinfo.h>
#include "functionalext.h"
typedef void (*TEST_FUN)();
/**
* @tc.name : get_nprocs_0100
* @tc.desc : Verify the number of CPUs being used
* @tc.level : Level 0
*/
void get_nprocs_0100(void)
{
int result;
result = get_nprocs();
bool flag = false;
if (result > 0) {
flag = true;
}
EXPECT_TRUE("fpathconf_0100", true);
}
TEST_FUN G_Fun_Array[] = {
get_nprocs_0100,
};
int main()
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
G_Fun_Array[pos]();
}
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <sys/sysinfo.h>
#include "functionalext.h"
typedef void (*TEST_FUN)();
/**
* @tc.name : fpathconf_0100
* @tc.desc : Verify the number of CPUs obtained
* @tc.level : Level 0
*/
void get_nprocs_0100(void)
{
int result;
result = get_nprocs_conf();
bool flag = false;
if (result > 0) {
flag = true;
}
EXPECT_TRUE("fpathconf_0100", true);
}
TEST_FUN G_Fun_Array[] = {
get_nprocs_0100,
};
int main()
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
G_Fun_Array[pos]();
}
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <sys/sysinfo.h>
#include "functionalext.h"
typedef void (*TEST_FUN)();
/**
* @tc.name : get_nprocs_0100
* @tc.desc : Verify the total number of pages fetched in memory
* @tc.level : Level 0
*/
void get_nprocs_0100(void)
{
int result;
result = get_phys_pages();
bool flag = false;
if (result > 0) {
flag = true;
}
EXPECT_TRUE("fpathconf_0100", true);
}
TEST_FUN G_Fun_Array[] = {
get_nprocs_0100,
};
int main()
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
G_Fun_Array[pos]();
}
return t_status;
}
\ No newline at end of file
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <limits.h>
#include <unistd.h>
#include "functionalext.h"
#define TEST_LIMIT_ERROR 1000
#define TEST_LIMIT_SIZE 3
struct limit_data {
int name;
long limit;
};
/**
* @tc.name : pathconf_0100
* @tc.desc : Get file-related configuration values
* @tc.level : Level 0
*/
void pathconf_0100(void)
{
struct limit_data data[TEST_LIMIT_SIZE] = {
{.name = _PC_PATH_MAX, .limit = PATH_MAX},
{.name = _PC_PIPE_BUF, .limit = PIPE_BUF},
{.name = _PC_NAME_MAX, .limit = NAME_MAX},
};
int i;
long ret;
for (i = 0; i < TEST_LIMIT_SIZE; i++) {
ret = pathconf(".", data[i].name);
EXPECT_EQ("pathconf_0100", ret, data[i].limit);
}
}
/**
* @tc.name : pathconf_0200
* @tc.desc : Provide exception parameters to get configuration values related to files
* @tc.level : Level 2
*/
void pathconf_0200(void)
{
long ret = pathconf(".", TEST_LIMIT_ERROR);
EXPECT_EQ("pathconf_0200", ret, ERREXPECT);
ret = pathconf(NULL, PATH_MAX);
EXPECT_EQ("pathconf_0200", ret, ERREXPECT);
ret = pathconf("not_exist", PATH_MAX);
EXPECT_EQ("pathconf_0200", ret, ERREXPECT);
}
int main(void)
{
pathconf_0100();
pathconf_0200();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <string.h>
#include "test.h"
/**
* @tc.name : sysconf_0100
* @tc.desc : The maximum number of processes running concurrently by the test user
* @tc.level : Level 0
*/
void sysconf_0100(void)
{
long result = sysconf(_SC_CHILD_MAX);
if (result == 0) {
t_error("%s sysconf want get result is not zero", __func__);
}
}
/**
* @tc.name : sysconf_0200
* @tc.desc : Get the maximum number of open files for a process
* @tc.level : Level 0
*/
void sysconf_0200(void)
{
long result = sysconf(_SC_OPEN_MAX);
if (result == 0) {
t_error("%s sysconf want get result is not zero", __func__);
}
}
int main(int argc, char *argv[])
{
sysconf_0100();
sysconf_0200();
return t_status;
}
\ No newline at end of file
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
functionalext_supplement_conf_test = [
"sysconf",
"fpathconf",
"get_avphys_page",
"get_nprocs",
"get_nprocs_conf",
"get_phys_pages",
"pathconf",
]
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("../../../../test_template.gni")
import("test_src_functionalext_supplement_ctype.gni")
foreach(s, functionalext_supplement_ctype_test) {
test_unittest(s) {
target_dir = "functionalext/supplement/ctype"
}
}
group("functionalext_supplement_ctype_test") {
testonly = true
deps = []
foreach(s, functionalext_supplement_ctype_test) {
deps += [ ":${s}" ]
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <locale.h>
#include <stdlib.h>
#include "functionalext.h"
typedef void (*TEST_FUN)();
const ssize_t COUNT_ONE = 1;
const ssize_t COUNT_FOUR = 4;
/**
* @tc.name : __ctype_get_mb_cur_max_0100
* @tc.desc : Gets the maximum length of a multi-byte character (Western Language - Latin 1)
* @tc.level : Level 0
*/
void __ctype_get_mb_cur_max_0100()
{
setlocale(LC_ALL, ".1252");
ssize_t result;
result = __ctype_get_mb_cur_max();
EXPECT_TRUE("__ctype_get_mb_cur_max_0100", result > 0);
}
/**
* @tc.name : __ctype_get_mb_cur_max_0200
* @tc.desc : Gets the maximum length of a multi-byte character (UTF8)
* @tc.level : Level 0
*/
void __ctype_get_mb_cur_max_0200()
{
setlocale(LC_CTYPE, "zh_CN.utf8");
ssize_t result;
result = __ctype_get_mb_cur_max();
EXPECT_EQ("__ctype_get_mb_cur_max_0200", result, COUNT_FOUR);
}
/**
* @tc.name : __ctype_get_mb_cur_max_0300
* @tc.desc : Gets the maximum length of a multi-byte character (Chinese GBK)
* @tc.level : Level 0
*/
void __ctype_get_mb_cur_max_0300()
{
setlocale(LC_ALL, ".936");
ssize_t result;
result = __ctype_get_mb_cur_max();
EXPECT_EQ("__ctype_get_mb_cur_max_0300", result, COUNT_FOUR);
}
TEST_FUN G_Fun_Array[] = {
__ctype_get_mb_cur_max_0100,
__ctype_get_mb_cur_max_0200,
__ctype_get_mb_cur_max_0300,
};
int main()
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
G_Fun_Array[pos]();
}
return t_status;
}
\ No newline at end of file
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include "functionalext.h"
const int COUNT = 62;
const int EOK = 0;
/**
* @tc.name : isalnum_0100
* @tc.desc : The parameter c is an English letter, and it is judged that the input character is a letter.
* @tc.level : Level 0
*/
void isalnum_0100(void)
{
int ret = isalnum('a');
EXPECT_NE("isalnum_0100", ret, EOK);
}
/**
* @tc.name : isalnum_0200
* @tc.desc : The parameter c is an English number, and it is judged that the input character is a number.
* @tc.level : Level 0
*/
void isalnum_0200(void)
{
int ret = isalnum('1');
EXPECT_NE("isalnum_0200", ret, EOK);
}
/**
* @tc.name : isalnum_0300
* @tc.desc : The parameter c is an special character,
* and it is judged that the input character is not a letter or a number.
* @tc.level : Level 2
*/
void isalnum_0300(void)
{
int ret = isalnum('*');
EXPECT_EQ("isalnum_0300", ret, EOK);
}
/**
* @tc.name : isalnum_0400
* @tc.desc : Determine the number of letters and numbers in the ascii code table.
* @tc.level : Level 1
*/
void isalnum_0400(void)
{
int total = 0;
for (int i = 0; i < 128; i++) {
int ret = isalnum((char)i);
if (ret) {
total++;
}
}
EXPECT_EQ("isalnum_0400", total, COUNT);
}
int main(void)
{
isalnum_0100();
isalnum_0200();
isalnum_0300();
isalnum_0400();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include <locale.h>
#include <stdlib.h>
#include "functionalext.h"
const int COUNT = 62;
const int SIZE = 128;
/**
* @tc.name : isalnum_l_0100
* @tc.desc : Verify isalnum_l process success. The parameter c is an English letter,
* and it is judged that the input character is a letter
* @tc.level : Level 0
*/
void isalnum_l_0100(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isalnum_l('a', m_locale);
EXPECT_NE("isalnum_l_0100", ret, 0);
}
/**
* @tc.name : isalnum_l_0200
* @tc.desc : Verify isalnum_l process success. The parameter c is an English number,
* and it is judged that the input character is a number
* @tc.level : Level 0
*/
void isalnum_l_0200(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isalnum_l('1', m_locale);
EXPECT_NE("isalnum_l_0200", ret, 0);
}
/**
* @tc.name : isalnum_l_0300
* @tc.desc : Verify isalnum_l process success. The parameter c is an special character,
* and it is judged that the input character is not a letter or a number
* @tc.level : Level 2
*/
void isalnum_l_0300(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isalnum_l('*', m_locale);
EXPECT_EQ("isalnum_l_0300", ret, 0);
}
/**
* @tc.name : isalnum_l_0400
* @tc.desc : Verify isalnum_l process success. Determine the number of letters and numbers
* in the ascii code table
* @tc.level : Level 1
*/
void isalnum_l_0400(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int total = 0;
for (int i = 0; i < SIZE; i++) {
int ret = isalnum_l((char)i, m_locale);
if (ret) {
total++;
}
}
EXPECT_EQ("isalnum_l_0400", total, COUNT);
}
int main(void)
{
isalnum_l_0100();
isalnum_l_0200();
isalnum_l_0300();
isalnum_l_0400();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include "functionalext.h"
const int32_t COUNT_ZERO = 0;
/**
* @tc.name : isalpha_0100
* @tc.desc : Verify that the entered character is a letter (parameter is 'a')
* @tc.level : Level 0
*/
void isalpha_0100(void)
{
int ret = isalpha('a');
EXPECT_NE("isalpha_0100", ret, COUNT_ZERO);
}
/**
* @tc.name : isalpha_0200
* @tc.desc : Verify that the entered character is not a letter (parameter is 'A')
* @tc.level : Level 2
*/
void isalpha_0200(void)
{
int ret = isalpha('A');
EXPECT_NE("isalpha_0200", ret, COUNT_ZERO);
}
/**
* @tc.name : isalpha_0300
* @tc.desc : Verify that the entered character is not a letter (parameter is '1')
* @tc.level : Level 2
*/
void isalpha_0300(void)
{
int ret = isspace('1');
EXPECT_EQ("isalpha_0300", ret, COUNT_ZERO);
}
/**
* @tc.name : isalpha_0400
* @tc.desc : Verify that the entered character is not a letter (parameter is '【')
* @tc.level : Level 2
*/
void isalpha_0400(void)
{
int ret = isspace('[');
EXPECT_EQ("isalpha_0400", ret, COUNT_ZERO);
}
/**
* @tc.name : isalpha_0500
* @tc.desc : Verify the number of letters in the ascii code table
* @tc.level : Level 1
*/
void isalpha_0500(void)
{
int total = 0;
for (int i = 0; i < 128; i++)
{
int ret = isalpha((char)i);
if (ret)
{
total++;
}
}
EXPECT_EQ("isalpha_0500", total, 52);
}
int main(void)
{
isalpha_0100();
isalpha_0200();
isalpha_0300();
isalpha_0400();
isalpha_0500();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include <locale.h>
#include <stdlib.h>
#include "functionalext.h"
const int COUNT = 52;
const int SIZE = 128;
/*
* @tc.name : isalpha_l_0100
* @tc.desc : Verify isalpha_l process success. When that the entered character is a letter (parameter is 'a').
* @tc.level : Level 0
*/
void isalpha_l_0100(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isalpha_l('a', m_locale);
EXPECT_NE("isalpha_l_0100", ret, 0);
}
/*
* @tc.name : isalpha_l_0200
* @tc.desc : Verify isalpha_l process success. When the entered character is not a letter (parameter is '1').
* @tc.level : Level 2
*/
void isalpha_l_0200(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isalpha_l('1', m_locale);
EXPECT_EQ("isalpha_l_0200", ret, 0);
}
/*
* @tc.name : isalpha_l_0300
* @tc.desc : Verify isalpha_l process success. When the entered character is not a letter (parameter is '【').
* @tc.level : Level 2
*/
void isalpha_l_0300(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isalpha_l('[', m_locale);
EXPECT_EQ("isalpha_l_0300", ret, 0);
}
/*
* @tc.name : isalpha_l_0400
* @tc.desc : Verify isalpha_l process success. Verify the number of letters in the ascii code table.
* @tc.level : Level 1
*/
void isalpha_l_0400(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int total = 0;
for (int i = 0; i < SIZE; i++) {
int ret = isalpha_l((char)i, m_locale);
if (ret) {
total++;
}
}
EXPECT_EQ("isalpha_l_0400", total, COUNT);
}
int main(void)
{
isalpha_l_0100();
isalpha_l_0200();
isalpha_l_0300();
isalpha_l_0400();
return t_status;
}
\ No newline at end of file
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include "functionalext.h"
#define TEST_DATA_COUNT 5
/**
* @tc.name : isascii_0100
* @tc.desc : Test if character is ascii
* @tc.level : Level 0
*/
void isascii_0100(void)
{
const unsigned char ascii[TEST_DATA_COUNT] = {0x10, 0x20, 0x74, 0x34, 0x7f};
const unsigned char not_ascii[TEST_DATA_COUNT] = {0x80, 0xef, 0xab, 0x91, 0xfe};
int i;
for (i = 0; i < TEST_DATA_COUNT; i++) {
EXPECT_EQ("isascii_0100", isascii(ascii[i]), ONREXPECT);
}
for (i = 0; i < TEST_DATA_COUNT; i++) {
EXPECT_EQ("isascii_0100", isascii(not_ascii[i]), CMPFLAG);
}
}
int main(void)
{
isascii_0100();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include "functionalext.h"
const int RET = 0;
const int COUNT = 2;
/**
* @tc.name : isblank_0100
* @tc.desc : The parameter c is a space (' '), and the input character is judged to be a space.
* @tc.level : Level 0
*/
void isblank_0100(void)
{
int ret = isblank(' ');
EXPECT_NE("isblank_0100", ret, RET);
}
/**
* @tc.name : isblank_0200
* @tc.desc : The parameter c is a carriage return ('\t'), and the input character is judged to be a space.
* @tc.level : Level 0
*/
void isblank_0200(void)
{
int ret = isblank('\t');
EXPECT_NE("isblank_0200", ret, RET);
}
/**
* @tc.name : isblank_0300
* @tc.desc : The parameter c is carriage return ('\r'), which determines that the input character is not a space.
* @tc.level : Level 2
*/
void isblank_0300(void)
{
int ret = isblank('\r');
EXPECT_EQ("isblank_0300", ret, RET);
}
/**
* @tc.name : isblank_0400
* @tc.desc : The parameter c is a newline ('\n'), judging that the input character is not a space.
* @tc.level : Level 2
*/
void isblank_0400(void)
{
int ret = isblank('\n');
EXPECT_EQ("isblank_0400", ret, RET);
}
/**
* @tc.name : isblank_0500
* @tc.desc : The parameter c is the vertical positioning character ('\v'),
* which judges that the input character is not a space.
* @tc.level : Level 2
*/
void isblank_0500(void)
{
int ret = isblank('\v');
EXPECT_EQ("isblank_0500", ret, RET);
}
/**
* @tc.name : isblank_0600
* @tc.desc : The parameter c is page turning ('\f'), which determines that the input character is not a space.
* @tc.level : Level 2
*/
void isblank_0600(void)
{
int ret = isblank('\f');
EXPECT_EQ("isblank_0600", ret, RET);
}
/**
* @tc.name : isblank_0700
* @tc.desc : The parameter c is an English letter, and it is judged that the input character is not a space.
* @tc.level : Level 2
*/
void isblank_0700(void)
{
int ret = isblank('a');
EXPECT_EQ("isblank_0700", ret, RET);
}
/**
* @tc.name : isblank_0800
* @tc.desc : The parameter c is alphanumeric, and it is judged that the input character is not a space.
* @tc.level : Level 2
*/
void isblank_0800(void)
{
int ret = isblank('6');
EXPECT_EQ("isblank_0800", ret, RET);
}
/**
* @tc.name : isblank_0900
* @tc.desc : The parameter c is a special character, and it is judged that the input character is not a space.
* @tc.level : Level 2
*/
void isblank_0900(void)
{
int ret = isblank('#');
EXPECT_EQ("isblank_0900", ret, RET);
}
/**
* @tc.name : isblank_1000
* @tc.desc : Determine the number of space characters in the ascii code table.
* @tc.level : Level 1
*/
void isblank_1000(void)
{
int total = 0;
for (int i = 0; i < 128; i++) {
int ret = isblank((char)i);
if (ret) {
total++;
}
}
EXPECT_EQ("isblank_1000", total, COUNT);
}
int main(void)
{
isblank_0100();
isblank_0200();
isblank_0300();
isblank_0400();
isblank_0500();
isblank_0600();
isblank_0700();
isblank_0800();
isblank_0900();
isblank_1000();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include <locale.h>
#include <stdlib.h>
#include "functionalext.h"
const int COUNT = 2;
const int SIZE = 128;
/**
* @tc.name : isblank_l_0100
* @tc.desc : Verify isblank_l process success. When the parameter c is a space (' '),
* and the input character is judged to be a space.
* @tc.level : Level 0
*/
void isblank_l_0100(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isblank_l(' ', m_locale);
EXPECT_NE("isblank_0100", ret, 0);
}
/**
* @tc.name : isblank_l_0200
* @tc.desc : Verify isblank_l process success. When the parameter c is a carriage return ('\t'),
* and the input character is judged to be a space.
* @tc.level : Level0
*/
void isblank_l_0200(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isblank_l('\t', m_locale);
EXPECT_NE("isblank_0200", ret, 0);
}
/**
* @tc.name : isblank_l_0300
* @tc.desc : Verify isblank_l process success. When the parameter c is carriage return ('\r'),
* which determines that the input character is not a space.
* @tc.level : Level2
*/
void isblank_l_0300(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isblank_l('\r', m_locale);
EXPECT_EQ("isblank_0300", ret, 0);
}
/**
* @tc.name : isblank_l_0400
* @tc.desc : Verify isblank_l process success. When the parameter c is a newline ('\n'),
* judging that the input character is not a space.
* @tc.level : Level2
*/
void isblank_l_0400(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isblank_l('\n', m_locale);
EXPECT_EQ("isblank_l_0400", ret, 0);
}
/**
* @tc.name : isblank_l_0500
* @tc.desc : Verify isblank_l process success. When the parameter c is the vertical positioning character ('\v'),
* which judges that the input character is not a space.
* @tc.level : Level 2
*/
void isblank_l_0500(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isblank_l('\v', m_locale);
EXPECT_EQ("isblank_l_0500", ret, 0);
}
/**
* @tc.name : isblank_0600
* @tc.desc : Verify isblank_l process success. When the parameter c is page turning ('\f'),
* which determines that the input character is not a space.
* @tc.level : Level2
*/
void isblank_l_0600(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isblank_l('\f', m_locale);
EXPECT_EQ("isblank_l_0600", ret, 0);
}
/**
* @tc.name : isblank_l_0700
* @tc.desc : Verify isblank_l process success. When the parameter c is an English letter,
* and it is judged that the input character is not a space.
* @tc.level : Level2
*/
void isblank_l_0700(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isblank_l('a', m_locale);
EXPECT_EQ("isblank_l_0700", ret, 0);
}
/**
* @tc.name : isblank_l_0800
* @tc.desc : Verify isblank_l process success. When the parameter c is alphanumeric,
* and it is judged that the input character is not a space.
* @tc.level : Level2
*/
void isblank_l_0800(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isblank_l('1', m_locale);
EXPECT_EQ("isblank_0800", ret, 0);
}
/**
* @tc.name : isblank_l_0900
* @tc.desc : Verify isblank_l process success. When the parameter c is a special character,
* and it is judged that the input character is not a space.
* @tc.level : Level2
*/
void isblank_l_0900(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isblank_l('#', m_locale);
EXPECT_EQ("isblank_l_0900", ret, 0);
}
/**
* @tc.name : isblank_l_1000
* @tc.desc : Verify isblank_l process success. Determine the number of space characters in the ascii code table.
* @tc.level : Level1
*/
void isblank_l_1000(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int total = 0;
for (int i = 0; i < SIZE; i++) {
int ret = isblank_l((char)i, m_locale);
if (ret) {
total++;
}
}
EXPECT_EQ("isblank_l_1000", total, COUNT);
}
int main(void)
{
isblank_l_0100();
isblank_l_0200();
isblank_l_0300();
isblank_l_0400();
isblank_l_0500();
isblank_l_0600();
isblank_l_0700();
isblank_l_0800();
isblank_l_0900();
isblank_l_1000();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include "functionalext.h"
const int RET = 0;
const int COUNT = 33;
/**
* @tc.name : iscntrl_0100
* @tc.desc : If the parameter c is 0, it is judged that the input character is a control character.
* @tc.level : Level 0
*/
void iscntrl_0100(void)
{
int ret = iscntrl(0);
EXPECT_NE("iscntrl_0100", ret, RET);
}
/**
* @tc.name : iscntrl_0200
* @tc.desc : The parameter c is 31, and the input character is judged to be a control character.
* @tc.level : Level 0
*/
void iscntrl_0200(void)
{
int ret = iscntrl(31);
EXPECT_NE("iscntrl_0200", ret, RET);
}
/**
* @tc.name : iscntrl_0300
* @tc.desc : The parameter c is 127, and the input character is judged to be a control character.
* @tc.level : Level 2
*/
void iscntrl_0300(void)
{
int ret = iscntrl(127);
EXPECT_NE("iscntrl_0300", ret, RET);
}
/**
* @tc.name : iscntrl_0400
* @tc.desc : The parameter c is a special character, and it is judged that the input
* character is not a control character.
* @tc.level : Level 2
*/
void iscntrl_0400(void)
{
int ret = iscntrl('[');
EXPECT_EQ("iscntrl_0400", ret, RET);
}
/**
* @tc.name : iscntrl_0500
* @tc.desc : Determine the number of control characters in the ascii code table.
* @tc.level : Level 1
*/
void iscntrl_0500(void)
{
int total = 0;
for (int i = 0; i < 128; i++) {
int ret = iscntrl((char)i);
if (ret) {
total++;
}
}
EXPECT_EQ("iscntrl_0500", total, COUNT);
}
int main(void)
{
iscntrl_0100();
iscntrl_0200();
iscntrl_0300();
iscntrl_0400();
iscntrl_0500();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include <locale.h>
#include <stdlib.h>
#include "functionalext.h"
const int COUNT = 33;
const int SIZE = 128;
/**
* @tc.name : iscntrl_l_0100
* @tc.desc : Verify iscntrl_l process success. When the parameter c is 0,
* it is judged that the input character is a control character.
* @tc.level : Level 0
*/
void iscntrl_l_0100(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = iscntrl_l(0, m_locale);
EXPECT_NE("iscntrl_l_0100", ret, 0);
}
/**
* @tc.name : iscntrl_l_0200
* @tc.desc : Verify iscntrl_l process success. When the parameter c is 31, and the input character
* is judged to be a control character.
* @tc.level : Level 0
*/
void iscntrl_l_0200(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = iscntrl_l(31, m_locale);
EXPECT_NE("iscntrl_l_0200", ret, 0);
}
/**
* @tc.name : iscntrl_l_0300
* @tc.desc : Verify iscntrl_l process success. When the parameter c is 127, and the input character
* is judged to be acontrol character.
* @tc.level : Level 2
*/
void iscntrl_l_0300(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = iscntrl_l(127, m_locale);
EXPECT_NE("iscntrl_l_0300", ret, 0);
}
/**
* @tc.name : iscntrl_l_0400
* @tc.desc : Verify iscntrl_l process success. When the parameter c is a special character, and it is judged that
* the input character is not a control character.
* @tc.level : Level 2
*/
void iscntrl_l_0400(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = iscntrl_l('[', m_locale);
EXPECT_EQ("iscntrl_l_0400", ret, 0);
}
/**
* @tc.name : iscntrl_l_0500
* @tc.desc : Verify iscntrl_l process success. Determine the number of control characters in ascii code table.
* @tc.level : Level 1
*/
void iscntrl_l_0500(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int total = 0;
for (int i = 0; i < SIZE; i++) {
int ret = iscntrl_l((char)i, m_locale);
if (ret) {
total++;
}
}
EXPECT_EQ("iscntrl_l_0500", total, COUNT);
}
int main(void)
{
iscntrl_l_0100();
iscntrl_l_0200();
iscntrl_l_0300();
iscntrl_l_0400();
iscntrl_l_0500();
return t_status;
}
\ No newline at end of file
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include "functionalext.h"
/**
* @tc.name : isdigit_l_0100
* @tc.desc : Whether the characters in a string is numeric characters
* @tc.level : Level 0
*/
void isdigit_l_0100(void)
{
const char *str = "0123456789";
const char *p = str;
while (*p++ && *p != '\0') {
int ret = isdigit_l(*p, NULL);
EXPECT_EQ("isdigit_l_0100", ret, ONREXPECT);
}
}
/**
* @tc.name : isdigit_l_0200
* @tc.desc : Whether a character in a string is a non-numeric character
* @tc.level : Level 2
*/
void isdigit_l_0200(void)
{
const char *str = "!@hHiIjJZz";
const char *p = str;
while (*p++ && *p != '\0') {
int ret = isdigit_l(*p, NULL);
EXPECT_EQ("isdigit_l_0200", ret, CMPFLAG);
}
}
/**
* @tc.name : isdigit_0100
* @tc.desc : Whether the characters in a string is numeric characters
* @tc.level : Level 0
*/
void isdigit_0100(void)
{
const char *str = "0123456789";
const char *p = str;
while (*p++ && *p != '\0') {
int ret = isdigit(*p);
EXPECT_EQ("isdigit_0100", ret, ONREXPECT);
}
}
/**
* @tc.name : isdigit_0200
* @tc.desc : Whether a character in a string is a non-numeric character
* @tc.level : Level 2
*/
void isdigit_0200(void)
{
const char *str = "!@hHiIjJZz";
const char *p = str;
while (*p++ && *p != '\0') {
int ret = isdigit(*p);
EXPECT_EQ("isdigit_0200", ret, CMPFLAG);
}
}
int main(void)
{
isdigit_l_0100();
isdigit_l_0200();
isdigit_0100();
isdigit_0200();
return t_status;
}
\ No newline at end of file
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include "functionalext.h"
/**
* @tc.name : isgraph_0100
* @tc.desc : Whether the characters in a string are printable characters
* @tc.level : Level 0
*/
void isgraph_0100(void)
{
const char *str = "1qw@#";
const char *p = str;
while (*p++ && *p != '\0') {
int ret = isgraph(*p);
EXPECT_EQ("isgraph_0100", ret, ONREXPECT);
}
}
/**
* @tc.name : isgraph_0200
* @tc.desc : Whether the characters in a string are none-printable characters
* @tc.level : Level 2
*/
void isgraph_0200(void)
{
const char *str = " ";
const char *p = str;
while (*p++ && *p != '\0') {
int ret = isgraph(*p);
EXPECT_EQ("isgraph_0200", ret, CMPFLAG);
}
}
int main(void)
{
isgraph_0100();
isgraph_0200();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include <locale.h>
#include <stdlib.h>
#include <wchar.h>
#include "functionalext.h"
const int COUNT = 94;
const int SIZE = 128;
/*
* @tc.name : isgraph_l_0100
* @tc.desc : Verify isgraph_l process success. When that the entered character is a letter (parameter is 'a'
* has a graphical representation).
* @tc.level : Level 0
*/
void isgraph_l_0100(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isgraph_l('a', m_locale);
EXPECT_NE("isgraph_l_0100", ret, 0);
}
/*
* @tc.name : isgraph_l_0200
* @tc.desc : Verify isgraph_l process success. When that the entered character is not a letter (parameter is '!'
* has a graphical representation).
* @tc.level : Level 0
*/
void isgraph_l_0200(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isgraph_l('!', m_locale);
EXPECT_NE("isgraph_l_0200", ret, 0);
}
/*
* @tc.name : isgraph_l_0300
* @tc.desc : Verify isgraph_l process success. When that the entered character is not has a graphical representation.
* @tc.level : Level 2
*/
void isgraph_l_0300(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isgraph_l(' ', m_locale);
EXPECT_EQ("isgraph_l_0300", ret, 0);
}
/**
* @tc.name : isgraph_l_0400
* @tc.desc : Verify isgraph_l process success. Determine the number of control characters in the ascii code table.
* @tc.level : Level 1
*/
void isgraph_l_0400(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int total = 0;
for (int i = 0; i < SIZE; i++) {
int ret = isgraph_l((char)i, m_locale);
if (ret) {
total++;
}
}
EXPECT_EQ("isgraph_l_0400", total, COUNT);
}
int main(void)
{
isgraph_l_0100();
isgraph_l_0200();
isgraph_l_0300();
isgraph_l_0400();
return t_status;
}
\ No newline at end of file
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include "functionalext.h"
const int COUNT = 26;
const int EOK = 0;
/**
* @tc.name : islower_0100
* @tc.desc : The parameter c is a lowercase letter,which determines the case of the input character.
* @tc.level : Level 0
*/
void islower_0100(void)
{
int ret = islower('a');
EXPECT_NE("islower_0100", ret, EOK);
}
/**
* @tc.name : islower_0200
* @tc.desc : The parameter c is a uppercase letter,which determines the case of the input character.
* @tc.level : Level 2
*/
void islower_0200(void)
{
int ret = islower('A');
EXPECT_EQ("islower_0200", ret, EOK);
}
/**
* @tc.name : islower_0300
* @tc.desc : The parameter c is a number,which determines the case of the input character.
* @tc.level : Level 2
*/
void islower_0300(void)
{
int ret = islower('1');
EXPECT_EQ("islower_0300", ret, EOK);
}
/**
* @tc.name : islower_0400
* @tc.desc : The parameter c is a special character,which determines the case of the input character.
* @tc.level : Level 2
*/
void islower_0400(void)
{
int ret = islower('[');
EXPECT_EQ("islower_0400", ret, EOK);
}
/**
* @tc.name : islower_0500
* @tc.desc : Determine the number of lowercase letters in the ascii code table.
* @tc.level : Level 1
*/
void islower_0500(void)
{
int total = 0;
for (int i = 0; i < 128; i++) {
int ret = islower((char)i);
if (ret) {
total++;
}
}
EXPECT_EQ("islower_0500", total, COUNT);
}
/**
* @tc.name : islower_l_0100
* @tc.desc : Whether the characters in a string is lower characters
* @tc.level : Level 0
*/
void islower_l_0100(void)
{
const char *str = "abcdegfhijklmnopqrstuvwxyz";
const char *p = str;
while (*p++ && *p != '\0') {
int ret = islower_l(*p, NULL);
EXPECT_EQ("islower_l_0100", ret, ONREXPECT);
}
}
/**
* @tc.name : islower_l_0200
* @tc.desc : Whether a character in a string is a non-lower character
* @tc.level : Level 2
*/
void islower_l_0200(void)
{
const char *str = "23!@ABCHIJZ";
const char *p = str;
while (*p++ && *p != '\0') {
int ret = islower_l(*p, NULL);
EXPECT_EQ("islower_l_0200", ret, CMPFLAG);
}
}
int main(void)
{
islower_0100();
islower_0200();
islower_0300();
islower_0400();
islower_0500();
islower_l_0100();
islower_l_0200();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include "functionalext.h"
const int RET = 0;
const int COUNT = 95;
/**
* @tc.name : isprint_0100
* @tc.desc : The parameter c is 32, and the input character is judged to be a printable character.
* @tc.level : Level 0
*/
void isprint_0100(void)
{
int ret = isprint(32);
EXPECT_NE("isprint_0100", ret, RET);
}
/**
* @tc.name : isprint_0200
* @tc.desc : The parameter c is 63, and the input character is judged to be a printable character.
* @tc.level : Level 0
*/
void isprint_0200(void)
{
int ret = isprint(63);
EXPECT_NE("isprint_0200", ret, RET);
}
/**
* @tc.name : isprint_0300
* @tc.desc : The parameter c is 126, and the input character is judged to be a printable character.
* @tc.level : Level 2
*/
void isprint_0300(void)
{
int ret = isprint(126);
EXPECT_NE("isprint_0300", ret, RET);
}
/**
* @tc.name : isprint_0400
* @tc.desc : The parameter c is the control character 20, which judges that the input character
* is not a printable character.
* @tc.level : Level 2
*/
void isprint_0400(void)
{
int ret = isprint(20);
EXPECT_EQ("isprint_0400", ret, RET);
}
/**
* @tc.name : isprint_0500
* @tc.desc : Determine the number of printable characters in the ascii code table.
* @tc.level : Level 1
*/
void isprint_0500(void)
{
int total = 0;
for (int i = 0; i < 128; i++) {
int ret = isprint((char)i);
if (ret) {
total++;
}
}
EXPECT_EQ("isprint_0500", total, COUNT);
}
int main(void)
{
isprint_0100();
isprint_0200();
isprint_0300();
isprint_0400();
isprint_0500();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include <locale.h>
#include <stdlib.h>
#include "functionalext.h"
const int COUNT = 95;
const int SIZE = 128;
/**
* @tc.name : isprint_l_0100
* @tc.desc : Verify isprint_l process success. When the parameter c is 32, and the input character is judged
* to be a printable character.
* @tc.level : Level 0
*/
void isprint_l_0100(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isprint_l(32, m_locale);
EXPECT_NE("isprint_l_0100", ret, 0);
}
/**
* @tc.name : isprint_l_0200
* @tc.desc : Verify isprint_l process success. Whent the parameter c is 63, and the input character is judged
* to be a printable character.
* @tc.level : Level 0
*/
void isprint_l_0200(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isprint_l(63, m_locale);
EXPECT_NE("isprint_l_0200", ret, 0);
}
/**
* @tc.name : isprint_l_0300
* @tc.desc : Verify isprint_l process success. Whent the parameter c is 126, and the input character is judged
* to be a printable character.
* @tc.level : Level 2
*/
void isprint_l_0300(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isprint_l(126, m_locale);
EXPECT_NE("isprint_l_0300", ret, 0);
}
/**
* @tc.name : isprint_l_0400
* @tc.desc : Verify isprint_l process success. Whent the parameter c is the control character 20, which judges
* that the input character is not a printable character.
* @tc.level : Level 2
*/
void isprint_l_0400(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isprint_l(20, m_locale);
EXPECT_EQ("isprint_l_0400", ret, 0);
}
/**
* @tc.name : isprint_l_0500
* @tc.desc : Verify isprint_l process success. Determine the number of printable characters in the ascii code
* table.
* @tc.level : Level 1
*/
void isprint_l_0500(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int total = 0;
for (int i = 0; i < SIZE; i++) {
int ret = isprint_l((char)i, m_locale);
if (ret) {
total++;
}
}
EXPECT_EQ("isprint_l_0500", total, COUNT);
}
int main(void)
{
isprint_l_0100();
isprint_l_0200();
isprint_l_0300();
isprint_l_0400();
isprint_l_0500();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include <dlfcn.h>
#include <errno.h>
#include <locale.h>
#include <stdio.h>
#include <string.h>
#include <wchar.h>
#include <wctype.h>
#include "functionalext.h"
/**
* @tc.name : ispunct_0100
* @tc.desc : Determine whether the input character is a punctuation mark or a special symbol.
* @tc.level : Level 0
*/
void ispunct_0100(void)
{
int var1 = 44;
int ret = ispunct(var1);
EXPECT_NE("ispunct_0100", ret, 0);
}
/**
* @tc.name : ispunct_0200
* @tc.desc : Determine whether the input character is a punctuation mark or a special symbol.
* @tc.level : Level 0
*/
void ispunct_0200(void)
{
int var1 = 64;
int ret = ispunct(var1);
EXPECT_NE("ispunct_0200", ret, 0);
}
/**
* @tc.name : ispunct_0300
* @tc.desc : Determine whether the input character is a punctuation mark or a special symbol.
* @tc.level : Level 0
*/
void ispunct_0300(void)
{
int var1 = 94;
int ret = ispunct(var1);
EXPECT_NE("ispunct_0300", ret, 0);
}
/**
* @tc.name : ispunct_0400
* @tc.desc : Determine if the input character is not a punctuation mark or a special symbol.
* @tc.level : Level 2
*/
void ispunct_0400(void)
{
int var1 = 65;
int ret = ispunct(var1);
EXPECT_EQ("ispunct_0400", ret, 0);
}
/**
* @tc.name : ispunct_0500
* @tc.desc : Determine the number of punctuation marks or special symbols in the ascii code table.
* @tc.level : Level 1
*/
void ispunct_0500(void)
{
int cout = 0;
for (int i = 0; i < 128; i++) {
if (ispunct(i)) {
cout++;
}
}
EXPECT_EQ("ispunct_0500", cout, 32);
}
int main(void)
{
ispunct_0100();
ispunct_0200();
ispunct_0300();
ispunct_0400();
ispunct_0500();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include <locale.h>
#include <stdlib.h>
#include "functionalext.h"
const int SIZE = 128;
const int RESULT_SIZE = 32;
/*
* @tc.name : ispunct_l_0100
* @tc.desc : Verify ispunct_l process success. When the input character is a punctuation mark or a special symbol.
* @tc.level : Level 0
*/
void ispunct_l_0100(void)
{
int var1 = 44;
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = ispunct_l(var1, m_locale);
EXPECT_NE("ispunct_l_0100", ret, 0);
}
/*
* @tc.name : ispunct_l_0200
* @tc.desc : Verify ispunct_l process success. When the input character is a punctuation mark or a special symbol.
* @tc.level : Level 0
*/
void ispunct_l_0200(void)
{
int var1 = 64;
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = ispunct_l(var1, m_locale);
EXPECT_NE("ispunct_l_0200", ret, 0);
}
/*
* @tc.name : ispunct_l_0300
* @tc.desc : Verify ispunct_l process success. When the input character is a punctuation mark or a special symbol.
* @tc.level : Level 0
*/
void ispunct_l_0300(void)
{
int var1 = 94;
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = ispunct_l(var1, m_locale);
EXPECT_NE("ispunct_l_0300", ret, 0);
}
/*
* @tc.name : ispunct_l_0400
* @tc.desc : Verify ispunct_l process success. When input character is not a punctuation mark or a special symbol.
* @tc.level : Level 2
*/
void ispunct_l_0400(void)
{
int var1 = 65;
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = ispunct_l(var1, m_locale);
EXPECT_EQ("ispunct_l_0400", ret, 0);
}
/*
* @tc.name : ispunct_l_0500
* @tc.desc : Verify ispunct_l process success. When the number of punctuation marks or special symbols
* in the ascii code table.
* @tc.level : Level 1
*/
void ispunct_l_0500(void)
{
int cout = 0;
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
for (int i = 0; i < SIZE; i++) {
if (ispunct_l(i, m_locale)) {
cout++;
}
}
EXPECT_EQ("ispunct_l_0500", cout, RESULT_SIZE);
}
int main(void)
{
ispunct_l_0100();
ispunct_l_0200();
ispunct_l_0300();
ispunct_l_0400();
ispunct_l_0500();
return t_status;
}
\ No newline at end of file
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "functionalext.h"
const int32_t COUJNT_ZERO = 0;
const int32_t COUJNT_SIX = 6;
/*
* @tc.name : isspace_0100
* @tc.desc : Verify that the input character is a space (the parameter is a space)
* @tc.level : Level 0
*/
void isspace_0100(void)
{
int ret = isspace(' ');
EXPECT_NE("isspace_0100", ret, COUJNT_ZERO);
}
/*
* @tc.name : isspace_0200
* @tc.desc : Verify that the input character is a space (parameter is \r)
* @tc.level : Level 1
*/
void isspace_0200(void)
{
int ret = isspace('\r');
EXPECT_NE("isspace_0200", ret, COUJNT_ZERO);
}
/*
* @tc.name : isspace_0300
* @tc.desc : Verify that the input character is a space (parameter is \n)
* @tc.level : Level 1
*/
void isspace_0300(void)
{
int ret = isspace('\n');
EXPECT_NE("isspace_0300", ret, COUJNT_ZERO);
}
/*
* @tc.name : isspace_0400
* @tc.desc : EVerify that the input character is a space (parameter is \v)
* @tc.level : Level 1
*/
void isspace_0400(void)
{
int ret = isspace('\v');
EXPECT_NE("isspace_0400", ret, COUJNT_ZERO);
}
/*
* @tc.name : isspace_0500
* @tc.desc : Verify that the input character is a space (parameter is \f)
* @tc.level : Level 1
*/
void isspace_0500(void)
{
int ret = isspace('\f');
EXPECT_NE("isspace_0500", ret, COUJNT_ZERO);
}
/*
* @tc.name : isspace_0600
* @tc.desc : Verify that the input character is not a space (parameter is 'a')
* @tc.level : Level 2
*/
void isspace_0600(void)
{
int ret = isspace('a');
EXPECT_EQ("isspace_0600", ret, COUJNT_ZERO);
}
/*
* @tc.name : isspace_0700
* @tc.desc : Verify that the input character is not a space (parameter is '6')
* @tc.level : Level 2
*/
void isspace_0700(void)
{
int ret = isspace('6');
EXPECT_EQ("isspace_0700", ret, COUJNT_ZERO);
}
/*
* @tc.name : isspace_0800
* @tc.desc : Verify that the input character is not a space (parameter is '#')
* @tc.level : Level 2
*/
void isspace_0800(void)
{
int ret = isspace('#');
EXPECT_EQ("isspace_0800", ret, COUJNT_ZERO);
}
/*
* @tc.name : isspace_0900
* @tc.desc : Verify the number of characters in the ascii code table
* @tc.level : Level 1
*/
void isspace_0900(void)
{
int total = 0;
for (int i = 0; i < 128; i++) {
int ret = isspace((char)i);
if (ret) {
total++;
}
}
EXPECT_EQ("isspace_0900", total, COUJNT_SIX);
}
int main(void)
{
isspace_0100();
isspace_0200();
isspace_0300();
isspace_0400();
isspace_0500();
isspace_0600();
isspace_0700();
isspace_0800();
isspace_0900();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include <locale.h>
#include <stdlib.h>
#include "functionalext.h"
const int SIZE = 128;
const int RETSIZE = 6;
/*
* @tc.name : isspace_l_0100
* @tc.desc : Verify isprint_l process success. When the input character is a space (the parameter is a space)
* @tc.level : Level 0
*/
void isspace_l_0100(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isspace_l(' ', m_locale);
EXPECT_NE("isspace_l_0100", ret, 0);
}
/*
* @tc.name : isspace_l_0200
* @tc.desc : Verify isprint_l process success. When the input character is a space (parameter is \r)
* @tc.level : Level 1
*/
void isspace_l_0200(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isspace_l('\r', m_locale);
EXPECT_NE("isspace_l_0200", ret, 0);
}
/*
* @tc.name : isspace_l_0300
* @tc.desc : Verify isprint_l process success. When the input character is a space (parameter is \n)
* @tc.level : Level 1
*/
void isspace_l_0300(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isspace_l('\n', m_locale);
EXPECT_NE("isspace_l_0300", ret, 0);
}
/*
* @tc.name : isspace_l_0400
* @tc.desc : Verify isprint_l process success. When the input character is a space (parameter is \v)
* @tc.level : Level 1
*/
void isspace_l_0400(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isspace_l('\v', m_locale);
EXPECT_NE("isspace_l_0400", ret, 0);
}
/*
* @tc.name : isspace_l_0500
* @tc.desc : Verify isprint_l process success. When the input character is a space (parameter is \f)
* @tc.level : Level 1
*/
void isspace_l_0500(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isspace_l('\f', m_locale);
EXPECT_NE("isspace_l_0500", ret, 0);
}
/*
* @tc.name : isspace_l_0600
* @tc.desc : Verify isprint_l process success. When the input character is not a space (parameter is 'a')
* @tc.level : Level 2
*/
void isspace_l_0600(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isspace_l('a', m_locale);
EXPECT_EQ("isspace_l_0600", ret, 0);
}
/*
* @tc.name : isspace_l_0700
* @tc.desc : Verify isprint_l process success. When the input character is not a space (parameter is '6')
* @tc.level : Level 2
*/
void isspace_l_0700(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isspace_l('6', m_locale);
EXPECT_EQ("isspace_l_0700", ret, 0);
}
/*
* @tc.name : isspace_l_0800
* @tc.desc : Verify isprint_l process success. When the input character is not a space (parameter is '#')
* @tc.level : Level 2
*/
void isspace_l_0800(void)
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int ret = isspace_l('#', m_locale);
EXPECT_EQ("isspace_l_0800", ret, 0);
}
/*
* @tc.name : isspace_l_0900
* @tc.desc : Verify isprint_l process success. Verify the number of characters in the ascii code table.
* @tc.level : Level 1
*/
void isspace_l_0900()
{
locale_t m_locale = newlocale(LC_ALL_MASK, "en_US.UTF-8", NULL);
int total = 0;
for (int i = 0; i < SIZE; i++) {
int ret = isspace_l((char)i, m_locale);
if (ret) {
total++;
}
}
EXPECT_EQ("isspace_l_0900", total, RETSIZE);
}
int main(void)
{
isspace_l_0100();
isspace_l_0200();
isspace_l_0300();
isspace_l_0400();
isspace_l_0500();
isspace_l_0600();
isspace_l_0700();
isspace_l_0800();
isspace_l_0900();
return t_status;
}
\ No newline at end of file
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include "functionalext.h"
const int COUNT = 26;
const int EOK = 0;
/**
* @tc.name : isupper_0100
* @tc.desc : The parameter c is a uppercase letter,which determines the case of the input character.
* @tc.level : Level 0
*/
void isupper_0100(void)
{
int ret = isupper('A');
EXPECT_NE("isupper_0100", ret, EOK);
}
/**
* @tc.name : isupper_0200
* @tc.desc : The parameter c is a lowercase letter,which determines the case of the input character.
* @tc.level : Level 2
*/
void isupper_0200(void)
{
int ret = isupper('a');
EXPECT_EQ("isupper_0200", ret, EOK);
}
/**
* @tc.name : isupper_0300
* @tc.desc : The parameter c is a number,which determines the case of the input character.
* @tc.level : Level 2
*/
void isupper_0300(void)
{
int ret = isupper('1');
EXPECT_EQ("isupper_0300", ret, EOK);
}
/**
* @tc.name : isupper_0400
* @tc.desc : The parameter c is a special character,which determines the case of the input character.
* @tc.level : Level 2
*/
void isupper_0400(void)
{
int ret = isupper('[');
EXPECT_EQ("isupper_0400", ret, EOK);
}
/**
* @tc.name : isupper_0500
* @tc.desc : Determine the number of uppercase letters in the ascii code table.
* @tc.level : Level 1
*/
void isupper_0500(void)
{
int total = 0;
for (int i = 0; i < 128; i++) {
int ret = isupper((char)i);
if (ret) {
total++;
}
}
EXPECT_EQ("isupper_0500", total, COUNT);
}
/**
* @tc.name : isupper_l_0100
* @tc.desc : Whether the characters in a string is upper characters
* @tc.level : Level 0
*/
void isupper_l_0100(void)
{
const char *str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const char *p = str;
while (*p++ && *p != '\0') {
int ret = isupper_l(*p, NULL);
EXPECT_EQ("isupper_l_0100", ret, ONREXPECT);
}
}
/**
* @tc.name : isupper_l_0200
* @tc.desc : Whether a character in a string is a non-upper character
* @tc.level : Level 2
*/
void isupper_l_0200(void)
{
const char *str = "23!@abcdefg";
const char *p = str;
while (*p++ && *p != '\0') {
int ret = isupper_l(*p, NULL);
EXPECT_EQ("isupper_l_0200", ret, CMPFLAG);
}
}
int main(void)
{
isupper_0100();
isupper_0200();
isupper_0300();
isupper_0400();
isupper_0500();
isupper_l_0100();
isupper_l_0200();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include <dlfcn.h>
#include <errno.h>
#include <locale.h>
#include <stdio.h>
#include <string.h>
#include <wchar.h>
#include <wctype.h>
#include "functionalext.h"
/**
* @tc.name : iswalhpa_0100
* @tc.desc : Determine if the input wide character is a letter.
* @tc.level : Level 0
*/
void iswalhpa_0100()
{
setlocale(LC_CTYPE, "UTF-8");
wchar_t str[] = L"a";
int ret;
int i = 0;
while (str[i]) {
ret = iswalpha(str[i]);
if (!ret) {
wprintf(L"'%lc' is not\n", str[i]);
}
i++;
}
EXPECT_NE("iswalhpa_0100", ret, 0);
}
/**
* @tc.name : iswalhpa_0200
* @tc.desc : Determine if the input wide character is a letter.
* @tc.level : Level 0
*/
void iswalhpa_0200()
{
setlocale(LC_CTYPE, "UTF-8");
wchar_t str[] = L"A";
int ret;
int i = 0;
while (str[i]) {
ret = iswalpha(str[i]);
if (!ret) {
wprintf(L"'%lc' is not\n", str[i]);
}
i++;
}
EXPECT_NE("iswalhpa_0200", ret, 0);
}
/**
* @tc.name : iswalhpa_0300
* @tc.desc : Determine if the input wide character is not a letter.
* @tc.level : Level 2
*/
void iswalhpa_0300()
{
setlocale(LC_CTYPE, "UTF-8");
wchar_t str[] = L"1";
int ret;
int i = 0;
while (str[i]) {
ret = iswalpha(str[i]);
if (ret) {
wprintf(L"'%lc' is alphabetic\n", str[i]);
}
i++;
}
EXPECT_EQ("iswalhpa_0300", ret, 0);
}
/**
* @tc.name : iswalhpa_0400
* @tc.desc : Determine if the input wide character is not a letter.
* @tc.level : Level 2
*/
void iswalhpa_0400()
{
setlocale(LC_CTYPE, "UTF-8");
wchar_t str[] = L"【";
int ret;
int i = 0;
while (str[i]) {
ret = iswalpha(str[i]);
if (ret) {
wprintf(L"'%lc' is alphabetic\n", str[i]);
}
i++;
}
EXPECT_EQ("iswalhpa_0400", ret, 0);
}
int main()
{
iswalhpa_0100();
iswalhpa_0200();
iswalhpa_0300();
iswalhpa_0400();
return t_status;
}
\ No newline at end of file
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include <wchar.h>
#include "functionalext.h"
/**
* @tc.name : iswalnum_0100
* @tc.desc : Tests whether the characters in the given string are numbers or letters
* @tc.level : Level 0
*/
void iswalnum_0100(void)
{
const wchar_t *str = L"aAÇçΔδ2";
int ret = 0;
while (*str) {
ret = iswalnum(*str);
EXPECT_EQ("iswalnum_0100", ret, ONREXPECT);
str++;
}
}
/**
* @tc.name : iswalnum_0200
* @tc.desc : Tests that the characters in the given string are not numbers or letters
* @tc.level : Level 2
*/
void iswalnum_0200(void)
{
const wchar_t *str = L"@#$*&!";
int ret = 0;
while (*str) {
ret = iswalnum(*str);
EXPECT_EQ("iswalnum_0200", ret, CMPFLAG);
str++;
}
}
int main(void)
{
iswalnum_0100();
iswalnum_0200();
return t_status;
}
\ No newline at end of file
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include <wchar.h>
#include <wctype.h>
#include "functionalext.h"
/**
* @tc.name : iswalpha_l_0100
* @tc.desc : Whether the characters in a wide string are letters
* @tc.level : Level 0
*/
void iswalpha_l_0100(void)
{
const wchar_t *str = L"aBcrWER";
const wchar_t *p = str;
while (*p++ && *p != '\0') {
int ret = iswalpha_l(*p, NULL);
EXPECT_EQ("iswalpha_l_0100", ret, ONREXPECT);
}
}
/**
* @tc.name : iswalpha_l_0200
* @tc.desc : Whether a character in a wide string is not a letter
* @tc.level : Level 2
*/
void iswalpha_l_0200(void)
{
const wchar_t *str = L"2!~*";
const wchar_t *p = str;
while (*p++ && *p != '\0') {
int ret = iswalpha_l(*p, NULL);
EXPECT_EQ("iswalpha_l_0200", ret, CMPFLAG);
}
}
int main(void)
{
iswalpha_l_0100();
iswalpha_l_0200();
return t_status;
}
\ No newline at end of file
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include <wchar.h>
#include <wctype.h>
#include "functionalext.h"
/**
* @tc.name : iswblank_l_0100
* @tc.desc : Whether a character in a wide string is a blank character
* @tc.level : Level 0
*/
void iswblank_l_0100(void)
{
const wchar_t *str = L" \t";
const wchar_t *p = str;
while (*p++ && *p != '\0') {
int ret = iswblank_l(*p, NULL);
EXPECT_EQ("iswblank_l_0100", ret, ONREXPECT);
}
}
/**
* @tc.name : iswblank_l_0200
* @tc.desc : Whether the characters in a wide string is blank characters
* @tc.level : Level 2
*/
void iswblank_l_0200(void)
{
const wchar_t *str = L"2!~*3Ad";
const wchar_t *p = str;
while (*p++ && *p != '\0') {
int ret = iswblank_l(*p, NULL);
EXPECT_EQ("iswblank_l_0200", ret, CMPFLAG);
}
}
/**
* @tc.name : iswblank_0100
* @tc.desc : Whether a character in a wide string is a blank character
* @tc.level : Level 0
*/
void iswblank_0100(void)
{
const wchar_t *str = L" \t";
const wchar_t *p = str;
while (*p++ && *p != '\0') {
int ret = iswblank(*p);
EXPECT_EQ("iswblank_0100", ret, ONREXPECT);
}
}
/**
* @tc.name : iswblank_0200
* @tc.desc : Whether the characters in a wide string is blank characters
* @tc.level : Level 2
*/
void iswblank_0200(void)
{
const wchar_t *str = L"2!~*3Ad";
const wchar_t *p = str;
while (*p++ && *p != '\0') {
int ret = iswblank(*p);
EXPECT_EQ("iswblank_0200", ret, CMPFLAG);
}
}
int main(void)
{
iswblank_l_0100();
iswblank_l_0200();
iswblank_0100();
iswblank_0200();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <ctype.h>
#include <locale.h>
#include <wchar.h>
#include <wctype.h>
#include "functionalext.h"
#include "test.h"
void iswcntrl_test(wchar_t ch, int want, char *func_name)
{
int result = iswcntrl(ch);
if (result != want) {
t_error("%s iswcntrl get result is %d are not %d\n", func_name, result, want);
}
}
/**
* @tc.name : iswcntrl_l_0100
* @tc.desc : Whether a character in a wide string is a control character
* @tc.level : Level 0
*/
void iswcntrl_l_0100(void)
{
const wchar_t *str = L"\b";
const wchar_t *p = str;
while (*p++ && *p != '\0') {
int ret = iswcntrl_l(*p, NULL);
EXPECT_EQ("iswcntrl_l_0100", ret, ONREXPECT);
}
}
/**
* @tc.name : iswcntrl_l_0200
* @tc.desc : Whether a character in a wide string is a non-control character
* @tc.level : Level 2
*/
void iswcntrl_l_0200(void)
{
const wchar_t *str = L"2!~*3Ad";
const wchar_t *p = str;
while (*p++ && *p != '\0') {
int ret = iswcntrl_l(*p, NULL);
EXPECT_EQ("iswcntrl_l_0200", ret, CMPFLAG);
}
}
int main(int argc, char *argv[])
{
char *ret = setlocale(LC_ALL, "en_US.utf8");
if (!ret) {
printf("\n");
}
/**
* @tc.name : iswcntrl_0100
* @tc.desc : Test if a wide character is a control character
* @tc.level : Level 0
*/
iswcntrl_test(L'\n', 1, "iswcntrl_0100");
/**
* @tc.name : iswcntrl_0200
* @tc.desc : Test whether the wide character is a control character, the incoming character is A
* @tc.level : Level 1
*/
iswcntrl_test(L'A', 0, "iswcntrl_0200");
/**
* @tc.name : iswcntrl_0300
* @tc.desc : Test whether the wide character is a control character, the incoming character is \u2028
* @tc.level : Level 1
*/
iswcntrl_test(L'\u2028', 1, "iswcntrl_0300");
/**
* @tc.name : iswcntrl_0400
* @tc.desc : Test whether the wide character is a control character, the incoming character is \ufff9
* @tc.level : Level 1
*/
iswcntrl_test(L'\ufff9', 1, "iswcntrl_0400");
iswcntrl_l_0100();
iswcntrl_l_0200();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <ctype.h>
#include <locale.h>
#include <wchar.h>
#include "test.h"
void iswctype_test(wchar_t ch, wctype_t wt, char *func_name, int want)
{
int result = iswctype(ch, wt);
if (result != want) {
t_error("%s iswctype get result is %d are not want %d", func_name, result, want);
}
}
int main(int argc, char *argv[])
{
wctype_t wt = wctype("alnum");
/**
* @tc.name : iswctype_0100
* @tc.desc : Use the iswctype function to determine whether the incoming wide character matches the incoming
* type
* @tc.level : Level 0
*/
iswctype_test(L'1', wt, "iswctype_0100", 1);
wt = wctype("alpha");
/**
* @tc.name : iswdigit_0200
* @tc.desc : Determine letter type wide characters
* @tc.level : Level 1
*/
iswctype_test(L'a', wt, "iswctype_0200", 1);
wt = wctype("blank");
/**
* @tc.name : iswctype_0300
* @tc.desc : Determine whitespace type wide character
* @tc.level : Level 1
*/
iswctype_test(L' ', wt, "iswctype_0300", 1);
wt = wctype("cntrl");
/**
* @tc.name : iswctype_0400
* @tc.desc : Determine the control type wide character
* @tc.level : Level 1
*/
iswctype_test(L'\n', wt, "iswctype_0400", 1);
wt = wctype("digit");
/**
* @tc.name : iswctype_0500
* @tc.desc : Determine decimal type wide characters
* @tc.level : Level 1
*/
iswctype_test(L'9', wt, "iswctype_0500", 1);
wt = wctype("lower");
/**
* @tc.name : iswctype_0600
* @tc.desc : Determining lowercase type wide characters
* @tc.level : Level 1
*/
iswctype_test(L'a', wt, "iswctype_0600", 1);
wt = wctype("print");
/**
* @tc.name : iswctype_0700
* @tc.desc : Determine the printable type wide character
* @tc.level : Level 1
*/
iswctype_test(L'u', wt, "iswctype_0700", 1);
wt = wctype("punct");
/**
* @tc.name : iswctype_0800
* @tc.desc : Determine the punctuation type wide character
* @tc.level : Level 1
*/
iswctype_test(L',', wt, "iswctype_0800", 1);
wt = wctype("upper");
/**
* @tc.name : iswctype_0900
* @tc.desc : Determine uppercase type wide characters
* @tc.level : Level 1
*/
iswctype_test(L'G', wt, "iswctype_0900", 1);
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <ctype.h>
#include <wchar.h>
#include <wctype.h>
#include "functionalext.h"
#include "test.h"
/**
* @tc.name : iswdigit_0100
* @tc.desc : Use the iswdigit function to determine whether the incoming wide character is a decimal number
* @tc.level : Level 0
*/
void iswdigit_0100(void)
{
wchar_t ch = L'9';
int result = iswdigit(ch);
if (result == 0) {
t_error("%s iswdigit get result is %d error", __func__, result);
}
}
/**
* @tc.name : iswdigit_0200
* @tc.desc : Test iswdigit when a non-decimal digit is passed in
* @tc.level : Level 1
*/
void iswdigit_0200(void)
{
wchar_t ch = L'A';
int result = iswdigit(ch);
if (result != 0) {
t_error("%s iswdigit get result is %d error", __func__, result);
}
}
/**
* @tc.name : iswdigit_l_0100
* @tc.desc : Whether a character in a wide string is a number character
* @tc.level : Level 0
*/
void iswdigit_l_0100(void)
{
const wchar_t *str = L"1234567890";
const wchar_t *p = str;
while (*p++ && *p != '\0') {
int ret = iswdigit_l(*p, NULL);
EXPECT_EQ("iswdigit_l_0100", ret, ONREXPECT);
}
}
/**
* @tc.name : iswdigit_l_0200
* @tc.desc : Whether a character in a wide string is a non-number character
* @tc.level : Level 2
*/
void iswdigit_l_0200(void)
{
const wchar_t *str = L"ewqWRE!~*Ad";
const wchar_t *p = str;
while (*p++ && *p != '\0') {
int ret = iswdigit_l(*p, NULL);
EXPECT_EQ("iswdigit_l_0200", ret, CMPFLAG);
}
}
int main(int argc, char *argv[])
{
iswdigit_0100();
iswdigit_0200();
iswdigit_l_0100();
iswdigit_l_0200();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <ctype.h>
#include <wchar.h>
#include <wctype.h>
#include "functionalext.h"
#include "test.h"
/**
* @tc.name : iswlower_0100
* @tc.desc : Use the iswlower method to determine whether the incoming wide character is a lowercase letter
* @tc.level : Level 0
*/
void iswlower_0100(void)
{
wchar_t ch = L'a';
int result = iswlower(ch);
if (result == 0) {
t_error("%s iswlower get result is %d error", __func__, result);
}
}
/**
* @tc.name : iswlower_0200
* @tc.desc : Test the return value of iswlower when uppercase letters are passed in
* @tc.level : Level 1
*/
void iswlower_0200(void)
{
wchar_t ch = L'A';
int result = iswlower(ch);
if (result != 0) {
t_error("%s iswlower get result is %d error", __func__, result);
}
}
/**
* @tc.name : iswlower_0300
* @tc.desc : Test the return value of iswlower when passing in a number
* @tc.level : Level 1
*/
void iswlower_0300(void)
{
wchar_t ch = L'1';
int result = iswlower(ch);
if (result != 0) {
t_error("%s iswlower get result is %d error", __func__, result);
}
}
/**
* @tc.name : iswlower_l_0100
* @tc.desc : Whether the characters in a wide string is lower character
* @tc.level : Level 0
*/
void iswlower_l_0100(void)
{
const wchar_t *str = L"abcdefghijklmnopqrstuvwxyz";
const wchar_t *p = str;
while (*p++ && *p != '\0') {
int ret = iswlower_l(*p, NULL);
EXPECT_EQ("iswlower_l_0100", ret, ONREXPECT);
}
}
/**
* @tc.name : iswlower_l_0200
* @tc.desc : Whether the characters in a wide string are non-lower character
* @tc.level : Level 2
*/
void iswlower_l_0200(void)
{
const wchar_t *str = L"12ABC!@#";
const wchar_t *p = str;
while (*p++ && *p != '\0') {
int ret = iswlower_l(*p, NULL);
EXPECT_EQ("iswlower_l_0200", ret, CMPFLAG);
}
}
int main(int argc, char *argv[])
{
iswlower_0100();
iswlower_0200();
iswlower_0300();
iswlower_l_0100();
iswlower_l_0200();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <ctype.h>
#include <wchar.h>
#include <wctype.h>
#include "functionalext.h"
#include "test.h"
/**
* @tc.name : iswprint_0100
* @tc.desc : Determine whether the incoming wide character can be printed by the iswprint method
* @tc.level : Level 1
*/
void iswprint_0100(void)
{
wchar_t ch = L'9';
int result = iswprint(ch);
if (result == 0) {
t_error("%s iswprint get result is %d error", __func__, result);
}
}
/**
* @tc.name : iswprint_0200
* @tc.desc : Test the iswprint method by passing in a non-printable wide character
* @tc.level : Level 1
*/
void iswprint_0200(void)
{
wchar_t ch = L'\n';
int result = iswprint(ch);
if (result != 0) {
t_error("%s iswprint get result is %d error", __func__, result);
}
}
/**
* @tc.name : iswprint_l_0100
* @tc.desc : Whether the characters in a wide string are printable characters
* @tc.level : Level 0
*/
void iswprint_l_0100(void)
{
const wchar_t *str = L"1Aa®Â Æ";
const wchar_t *p = str;
while (*p++ && *p != '\0') {
int ret = iswprint_l(*p, NULL);
EXPECT_EQ("iswprint_l_0100", ret, ONREXPECT);
}
}
/**
* @tc.name : iswprint_l_0200
* @tc.desc : Whether the characters in a wide string are non-printable characters
* @tc.level : Level 2
*/
void iswprint_l_0200(void)
{
const wchar_t *str = L"\a\b";
const wchar_t *p = str;
while (*p++ && *p != '\0') {
int ret = iswprint_l(*p, NULL);
EXPECT_EQ("iswprint_l_0200", ret, CMPFLAG);
}
}
int main(int argc, char *argv[])
{
iswprint_0100();
iswprint_0200();
iswprint_l_0100();
iswprint_l_0200();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include <stdio.h>
#include <wchar.h>
#include <wctype.h>
#include "functionalext.h"
#include "test.h"
/**
* @tc.name : iswpunct_0100
* @tc.desc : Use the iswpunct method to determine whether the incoming wide character is a punctuation mark
* @tc.level : Level 0
*/
void iswpunct_0100(void)
{
wchar_t ch = L',';
int result = iswpunct(ch);
if (result == 0) {
t_error("%s iswpunct get result is %d error", __func__, result);
}
}
/**
* @tc.name : iswpunct_0200
* @tc.desc : Test iswpunct method for wide characters passed in non-punctuation marks
* @tc.level : Level 1
*/
void iswpunct_0200(void)
{
wchar_t ch = L'A';
int result = iswpunct(ch);
if (result != 0) {
t_error("%s iswpunct get result is %d error", __func__, result);
}
}
/**
* @tc.name : iswpunct_l_0100
* @tc.desc : Whether the characters in a wide string are punctuation marks
* @tc.level : Level 0
*/
void iswpunct_l_0100(void)
{
const wchar_t *str = L"!!,。??";
const wchar_t *p = str;
while (*p++ && *p != '\0') {
int ret = iswpunct_l(*p, NULL);
EXPECT_EQ("iswpunct_l_0100", ret, ONREXPECT);
}
}
/**
* @tc.name : iswpunct_l_0200
* @tc.desc : Whether the characters in a wide string are non-punctuation marks
* @tc.level : Level 2
*/
void iswpunct_l_0200(void)
{
const wchar_t *str = L"1AaÂÆ";
const wchar_t *p = str;
while (*p++ && *p != '\0') {
int ret = iswpunct_l(*p, NULL);
EXPECT_EQ("iswpunct_l_0200", ret, CMPFLAG);
}
}
int main(int argc, char *argv[])
{
iswpunct_0100();
iswpunct_0200();
iswpunct_l_0100();
iswpunct_l_0200();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include <stdio.h>
#include <wchar.h>
#include <wctype.h>
#include "functionalext.h"
#include "test.h"
/**
* @tc.name : iswspace_0100
* @tc.desc : Use the iswspace method to determine whether the incoming wide character is a blank symbol
* @tc.level : Level 0
*/
void iswspace_0100(void)
{
wchar_t ch = L' ';
int result = iswspace(ch);
if (result == 0) {
t_error("%s iswspace get result is %d error", __func__, result);
}
}
/**
* @tc.name : iswspace_0200
* @tc.desc : Test iswpunct method for wide characters passing in non-whitespace characters
* @tc.level : Level 1
*/
void iswspace_0200(void)
{
wchar_t ch = L'A';
int result = iswspace(ch);
if (result != 0) {
t_error("%s iswspace get result is %d error", __func__, result);
}
}
/**
* @tc.name : iswspace_l_0100
* @tc.desc : Whether the characters in a wide string is whitespace character
* @tc.level : Level 0
*/
void iswspace_l_0100(void)
{
const wchar_t *str = L" \t\n\r";
const wchar_t *p = str;
while (*p++ && *p != '\0') {
int ret = iswspace_l(*p, NULL);
EXPECT_EQ("iswspace_l_0100", ret, ONREXPECT);
}
}
/**
* @tc.name : iswspace_l_0200
* @tc.desc : Whether the characters in a wide string are non-whitespace character
* @tc.level : Level 2
*/
void iswspace_l_0200(void)
{
const wchar_t *str = L"1AaÂÆ";
const wchar_t *p = str;
while (*p++ && *p != '\0') {
int ret = iswspace_l(*p, NULL);
EXPECT_EQ("iswspace_l_0200", ret, CMPFLAG);
}
}
int main(int argc, char *argv[])
{
iswspace_0100();
iswspace_0200();
iswspace_l_0100();
iswspace_l_0200();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include <stdio.h>
#include <wchar.h>
#include <wctype.h>
#include "functionalext.h"
#include "test.h"
/**
* @tc.name : iswupper_0100
* @tc.desc : Determine whether the incoming wide character is an uppercase letter by the iswupper method
* @tc.level : Level 0
*/
void iswupper_0100(void)
{
wchar_t ch = L'A';
int result = iswupper(ch);
if (result == 0) {
t_error("%s iswupper get result is %d error", __func__, result);
}
}
/**
* @tc.name : iswupper_0200
* @tc.desc : Test the return value of iswupper when lowercase letters are passed in
* @tc.level : Level 1
*/
void iswupper_0200(void)
{
wchar_t ch = L'a';
int result = iswupper(ch);
if (result != 0) {
t_error("%s iswupper get result is %d error", __func__, result);
}
}
/**
* @tc.name : iswupper_0300
* @tc.desc : Test iswupper return value when passing in a number
* @tc.level : Level 1
*/
void iswupper_0300(void)
{
wchar_t ch = L'1';
int result = iswupper(ch);
if (result != 0) {
t_error("%s iswupper get result is %d error", __func__, result);
}
}
/**
* @tc.name : iswupper_l_0100
* @tc.desc : Whether the characters in a wide string is upper character
* @tc.level : Level 0
*/
void iswupper_l_0100(void)
{
const wchar_t *str = L"ABCDEFG";
const wchar_t *p = str;
while (*p++ && *p != '\0') {
int ret = iswupper_l(*p, NULL);
EXPECT_EQ("iswupper_l_0100", ret, ONREXPECT);
}
}
/**
* @tc.name : iswupper_l_0200
* @tc.desc : Whether the characters in a wide string are non-upper character
* @tc.level : Level 2
*/
void iswupper_l_0200(void)
{
const wchar_t *str = L"abcefg1";
const wchar_t *p = str;
while (*p++ && *p != '\0') {
int ret = iswupper_l(*p, NULL);
EXPECT_EQ("iswupper_l_0200", ret, CMPFLAG);
}
}
int main(int argc, char *argv[])
{
iswupper_0100();
iswupper_0200();
iswupper_0300();
iswupper_l_0100();
iswupper_l_0200();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include <stdio.h>
#include <wchar.h>
#include <wctype.h>
#include "functionalext.h"
#include "test.h"
/**
* @tc.name : iswxdigit_0100
* @tc.desc : Use the iswxdigit method to determine whether the incoming wide character is a hexadecimal number
* @tc.level : Level 0
*/
void iswxdigit_0100(void)
{
wchar_t ch = L'A';
int result = iswxdigit(ch);
if (result == 0) {
t_error("%s iswxdigit get result is %d error", __func__, result);
}
}
/**
* @tc.name : iswxdigit_0200
* @tc.desc : Incoming digit test iswxdigit return value
* @tc.level : Level 1
*/
void iswxdigit_0200(void)
{
wchar_t ch = L'1';
int result = iswxdigit(ch);
if (result == 0) {
t_error("%s iswxdigit get result is %d error", __func__, result);
}
}
/**
* @tc.name : iswxdigit_0300
* @tc.desc : Pass in letters over F to test iswxdigit return value
* @tc.level : Level 1
*/
void iswxdigit_0300(void)
{
wchar_t ch = L'G';
int result = iswxdigit(ch);
if (result != 0) {
t_error("%s iswxdigit get result is %d error", __func__, result);
}
}
/**
* @tc.name : iswxdigit_l_0100
* @tc.desc : Whether the characters in a wide string is hexadecimal digit character
* @tc.level : Level 0
*/
void iswxdigit_l_0100(void)
{
const wchar_t *str = L"0123456789AaBbCcDdEeFf";
const wchar_t *p = str;
while (*p++ && *p != '\0') {
int ret = iswxdigit_l(*p, NULL);
EXPECT_EQ("iswxdigit_l_0100", ret, ONREXPECT);
}
}
/**
* @tc.name : iswxdigit_l_0200
* @tc.desc : Whether the characters in a wide string is non-hexadecimal digit character
* @tc.level : Level 2
*/
void iswxdigit_l_0200(void)
{
const wchar_t *str = L"!@hHiIjJZz";
const wchar_t *p = str;
while (*p++ && *p != '\0') {
int ret = iswxdigit_l(*p, NULL);
EXPECT_EQ("iswxdigit_l_0200", ret, CMPFLAG);
}
}
int main(int argc, char *argv[])
{
iswxdigit_0100();
iswxdigit_0200();
iswxdigit_0300();
iswxdigit_l_0100();
iswxdigit_l_0200();
return t_status;
}
\ No newline at end of file
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include "functionalext.h"
const int COUNT = 22;
const int EOK = 0;
/**
* @tc.name : isxdigit_0100
* @tc.desc : The parameter c is alphanumeric, and the input character is judged to be a hexadecimal number.
* @tc.level : Level 0
*/
void isxdigit_0100(void)
{
int ret = isxdigit('0');
EXPECT_NE("isxdigit_0100", ret, EOK);
}
/**
* @tc.name : isxdigit_0200
* @tc.desc : The parameter c is a valid English letter(uppercase),
* and the input character is judged to be a hexadecimal number.
* @tc.level : Level 0
*/
void isxdigit_0200(void)
{
int ret = isxdigit('F');
EXPECT_NE("isxdigit_0200", ret, EOK);
}
/**
* @tc.name : isxdigit_0300
* @tc.desc : The parameter c is a valid English letter(lowercase),
* and the input character is judged to be a hexadecimal number.
* @tc.level : Level 0
*/
void isxdigit_0300(void)
{
int ret = isxdigit('a');
EXPECT_NE("isxdigit_0300", ret, EOK);
}
/**
* @tc.name : isxdigit_0400
* @tc.desc : The parameter c is a invalid English letter(uppercase),
* and the input character is not a hexadecimal number.
* @tc.level : Level 2
*/
void isxdigit_0400(void)
{
int ret = isxdigit('G');
EXPECT_EQ("isxdigit_0400", ret, EOK);
}
/**
* @tc.name : isxdigit_0500
* @tc.desc : The parameter c is a special letter(%),
* and the input character is not a hexadecimal number.
* @tc.level : Level 2
*/
void isxdigit_0500(void)
{
int ret = isxdigit('%');
EXPECT_EQ("isxdigit_0500", ret, EOK);
}
/**
* @tc.name : isxdigit_0600
* @tc.desc : Determine the number of hexadecimal letters in the ascii code table.
* @tc.level : Level 2
*/
void isxdigit_0600(void)
{
int total = 0;
for (int i = 0; i < 128; i++) {
int ret = isxdigit((char)i);
if (ret) {
total++;
}
}
EXPECT_EQ("isxdigit_0600", total, COUNT);
}
/**
* @tc.name : isxdigit_l_0100
* @tc.desc : Whether the characters in a string is hexadecimal digit character
* @tc.level : Level 0
*/
void isxdigit_l_0100(void)
{
const char *str = "0123456789AaBbCcDdEeFf";
const char *p = str;
while (*p++ && *p != '\0') {
int ret = isxdigit_l(*p, NULL);
EXPECT_EQ("isxdigit_l_0100", ret, ONREXPECT);
}
}
/**
* @tc.name : isxdigit_l_0200
* @tc.desc : Whether the characters in a string is non-hexadecimal digit character
* @tc.level : Level 2
*/
void isxdigit_l_0200(void)
{
const char *str = "!@hHiIjJZz";
const char *p = str;
while (*p++ && *p != '\0') {
int ret = isxdigit_l(*p, NULL);
EXPECT_EQ("isxdigit_l_0200", ret, CMPFLAG);
}
}
int main(void)
{
isxdigit_0100();
isxdigit_0200();
isxdigit_0300();
isxdigit_0400();
isxdigit_0500();
isxdigit_0600();
isxdigit_l_0100();
isxdigit_l_0200();
return t_status;
}
\ No newline at end of file
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
functionalext_supplement_ctype_test = [
"isalnum_l",
"isalpha_l",
"isblank_l",
"iscntrl_l",
"isgraph_l",
"isprint_l",
"ispunct_l",
"isspace_l",
"wcwidth",
"tolower",
"toupper",
"iswcntrl",
"iswctype",
"iswdigit",
"iswlower",
"wcswidth",
"iswprint",
"toascii",
"towlower",
"iswpunct",
"iswspace",
"iswupper",
"iswxdigit",
"wctrans",
"towctrans",
"wctrans_l",
"wctype",
"isspace",
"__ctype_get_mb_cur_max",
"isalpha",
"ispunct",
"iswalhpa",
"isalnum",
"isblank",
"iscntrl",
"islower",
"isprint",
"isupper",
"isxdigit",
"isascii",
"isdigit",
"isgraph",
"iswalnum",
"iswalpha",
"iswblank",
]
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ctype.h>
#include "test.h"
/**
* @tc.name : toascii_0100
* @tc.desc : Convert a character to ASCII
* @tc.level : Level 0
*/
void toascii_0100(void)
{
int c1 = 'a' + 128;
char c2 = toascii(c1);
if (c2 != 'a') {
t_error("%s toascii failed. c2 id %c", __func__, c2);
}
}
/**
* @tc.name : toascii_0200
* @tc.desc : Convert a character to ASCII special symbol
* @tc.level : Level 1
*/
void toascii_0200(void)
{
int c1 = 33;
char c2 = toascii(c1);
if (c2 != '!') {
t_error("%s toascii failed. c2 id %c", __func__, c2);
}
}
/**
* @tc.name : toascii_0300
* @tc.desc : Convert a character to an ASCII number
* @tc.level : Level 1
*/
void toascii_0300(void)
{
int c1 = 48;
char c2 = toascii(c1);
if (c2 != '0') {
t_error("%s toascii failed. c2 id %c", __func__, c2);
}
}
int main(int argc, char *argv[])
{
toascii_0100();
toascii_0200();
toascii_0300();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <ctype.h>
#include "test.h"
/**
* @tc.name : tolower_0100
* @tc.desc : Convert uppercase to lowercase by tolower
* @tc.level : Level 0
*/
void tolower_0100(void)
{
char ch = 'A';
char result = tolower(ch);
if (result != 'a') {
t_error("%s tolower get result is %c but want get value a ", __func__, result);
}
}
/**
* @tc.name : tolower_0200
* @tc.desc : Test the result obtained by passing a number to tolower
* @tc.level : Level 1
*/
void tolower_0200(void)
{
char ch = 2;
char result = tolower(ch);
if (result != ch) {
t_error("%s tolower get result is %c but want get value %c ", __func__, result, ch);
}
}
/**
* @tc.name : tolower_0300
* @tc.desc : Test the result of passing lowercase letters to tolower
* @tc.level : Level 1
*/
void tolower_0300(void)
{
char ch = 'a';
char result = tolower(ch);
if (result != ch) {
t_error("%s tolower get result is %c but want get value %c ", __func__, result, ch);
}
}
/**
* @tc.name : tolower_0400
* @tc.desc : Test the result of passing special characters into tolower
* @tc.level : Level 2
*/
void tolower_0400(void)
{
char ch = '$';
char result = tolower(ch);
if (result != ch) {
t_error("%s tolower get result is %c but want get value %c ", __func__, result, ch);
}
}
int main(int argc, char *argv[])
{
tolower_0100();
tolower_0200();
tolower_0300();
tolower_0400();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <ctype.h>
#include "test.h"
/**
* @tc.name : toupper_0100
* @tc.desc : Convert lowercase to uppercase via toupper
* @tc.level : Level 0
*/
void toupper_0100(void)
{
char ch = 'a';
char result = toupper(ch);
if (result != 'A') {
t_error("%s toupper get result is %c but want get value A ", __func__, result);
}
}
/**
* @tc.name : toupper_0200
* @tc.desc : Test the result of passing numbers into toupper
* @tc.level : Level 1
*/
void toupper_0200(void)
{
char ch = 2;
char result = toupper(ch);
if (result != ch) {
t_error("%s toupper get result is %c but want get value %c ", __func__, result, ch);
}
}
/**
* @tc.name : toupper_0300
* @tc.desc : Test the result of passing capital letters into toupper
* @tc.level : Level 1
*/
void toupper_0300(void)
{
char ch = 'A';
char result = toupper(ch);
if (result != ch) {
t_error("%s toupper get result is %c but want get value %c ", __func__, result, ch);
}
}
/**
* @tc.name : toupper_0400
* @tc.desc : Test the result of passing special characters into toupper
* @tc.level : Level 2
*/
void toupper_0400(void)
{
char ch = '$';
char result = toupper(ch);
if (result != ch) {
t_error("%s toupper get result is %c but want get value %c ", __func__, result, ch);
}
}
int main(int argc, char *argv[])
{
toupper_0100();
toupper_0200();
toupper_0300();
toupper_0400();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <ctype.h>
#include <wchar.h>
#include <wctype.h>
#include "test.h"
/**
* @tc.name : towctrans_0100
* @tc.desc : Convert character of current type to lowercases
* @tc.level : Level 0
*/
void towctrans_0100(void)
{
wchar_t str[] = L"ABCD";
wctrans_t trans = wctrans("tolower");
for (int i = 0; i < wcslen(str); i++) {
str[i] = towctrans(str[i], trans);
}
if (wcscmp(str, L"abcd")) {
t_error("%s towctrans lower failed", __func__);
}
}
/**
* @tc.name : towctrans_0200
* @tc.desc : Convert character of current type to uppercase
* @tc.level : Level 1
*/
void towctrans_0200(void)
{
wchar_t str[] = L"abcd";
wctrans_t trans = wctrans("toupper");
for (int i = 0; i < wcslen(str); i++) {
str[i] = towctrans(str[i], trans);
}
if (wcscmp(str, L"ABCD")) {
t_error("%s towctrans upper failed", __func__);
}
}
/**
* @tc.name : towctrans_0300
* @tc.desc : Convert character of current type to uppercase
* @tc.level : Level 1
*/
void towctrans_0300(void)
{
wchar_t str[] = L"Abcd";
for (int i = 0; i < wcslen(str); i++) {
str[i] = towctrans(str[i], 0);
}
if (wcscmp(str, L"Abcd")) {
t_error("%s towctrans failed", __func__);
}
}
int main(int argc, char *argv[])
{
towctrans_0100();
towctrans_0200();
towctrans_0300();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <ctype.h>
#include <wctype.h>
#include "test.h"
/**
* @tc.name : towlower_0100
* @tc.desc : Convert wide characters to lowercase via towlower
* @tc.level : Level 0
*/
void towlower_0100(void)
{
wint_t wt = L'\u0190';
wint_t result = towlower(wt);
unsigned int want = 603;
if (result != want) {
t_error("%s towlower get result is %d are not 603\n", __func__, result);
}
}
/**
* @tc.name : towlower_0200
* @tc.desc : Test that the incoming character exceeds the function limit
* @tc.level : Level 1
*/
void towlower_0200(void)
{
wint_t wt = 0x20000;
wint_t result = towlower(wt);
if (result != wt) {
t_error("%s towlower get result is %d are not 0x20000\n", __func__, result);
}
}
int main(int argc, char *argv[])
{
towlower_0100();
towlower_0200();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <string.h>
#include <wchar.h>
#include <ctype.h>
#include "test.h"
const int WIDTH = 2;
const int ERR_RESULT = -1;
/**
* @tc.name : wcswidth_0100
* @tc.desc : Test wcswidth to get the number of wide string columns
* @tc.level : Level 0
*/
void wcswidth_0100(void)
{
int result = wcswidth(L"abc", WIDTH);
if (result != WIDTH) {
t_error("%s wcswidth get result is %s are not want 2\n", __func__, result);
}
}
/**
* @tc.name : wcswidth_0200
* @tc.desc : wcswidth result when wide string contains non-printing characters
* @tc.level : Level 1
*/
void wcswidth_0200(void)
{
int result = wcswidth(L"ab\t", WIDTH);
if (result != WIDTH) {
t_error("%s wcswidth get result is %s are not want 2\n", __func__, result);
}
}
/**
* @tc.name : wcswidth_0300
* @tc.desc : The result of wcswidth when nonprinting characters are included in the selection
* @tc.level : Level 2
*/
void wcswidth_0300(void)
{
int result = wcswidth(L"a\tb", WIDTH);
if (result != ERR_RESULT) {
t_error("%s wcswidth get result is %s are not want -1\n", __func__, result);
}
}
int main(int argc, char *argv[])
{
wcswidth_0100();
wcswidth_0200();
wcswidth_0300();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <string.h>
#include <wchar.h>
#include <ctype.h>
#include <wctype.h>
#include "test.h"
/**
* @tc.name : wctrans_0100
* @tc.desc : Test that wctrans returns a character conversion of a scalar type
* @tc.level : Level 0
*/
void wctrans_0100(void)
{
if (!wctrans("tolower")) {
t_error("%s wctrans error get result is NULL\n", __func__);
}
}
/**
* @tc.name : wctrans_0200
* @tc.desc : Test result of wctrans when incoming uppercase conversion
* @tc.level : Level 1
*/
void wctrans_0200(void)
{
if (!wctrans("toupper")) {
t_error("%s wctrans error get result is NULL\n", __func__);
}
}
/**
* @tc.name : wctrans_0300
* @tc.desc : Test the result of wctrans when passing in an exception parameter
* @tc.level : Level 2
*/
void wctrans_0300(void)
{
if (wctrans("monkeys")) {
t_error("%s wctrans error get result is not NULL\n", __func__);
}
}
int main(int argc, char *argv[])
{
wctrans_0100();
wctrans_0200();
wctrans_0300();
return t_status;
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <string.h>
#include <wchar.h>
#include <ctype.h>
#include <wctype.h>
#include "test.h"
/**
* @tc.name : wctrans_l_0100
* @tc.desc : Test that wctrans_l returns a character conversion of a scalar type
* @tc.level : Level 0
*/
void wctrans_l_0100(void)
{
if (!wctrans_l("tolower", NULL)) {
t_error("%s wctrans_l error get result is NULL\n", __func__);
}
}
/**
* @tc.name : wctrans_l_0200
* @tc.desc : Test result of wctrans_l when incoming uppercase conversion
* @tc.level : Level 1
*/
void wctrans_l_0200(void)
{
if (!wctrans_l("toupper", NULL)) {
t_error("%s wctrans_l error get result is NULL\n", __func__);
}
}
/**
* @tc.name : wctrans_l_0300
* @tc.desc : Test the result of wctrans_l when passing in an exception parameter
* @tc.level : Level 2
*/
void wctrans_l_0300(void)
{
if (wctrans_l("monkeys", NULL)) {
t_error("%s wctrans_l error get result is not NULL\n", __func__);
}
}
int main(int argc, char *argv[])
{
wctrans_l_0100();
wctrans_l_0200();
wctrans_l_0300();
return t_status;
}
\ No newline at end of file
此差异已折叠。
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <string.h>
#include <wchar.h>
#include <wctype.h>
#include "test.h"
const int INPUT_VALUE[12] = {
0x0300, 0x20dd, 0x00ad, 0x200b, 0x4e00, 0x9fff, 0x3400, 0x4dbf, 0x20000, 0x2a6df, 0xac00, 0xd7a3};
const int RESULT_VALUE = 2;
/**
* @tc.name : wcwidth_0100
* @tc.desc : Test that the wcwidth method returns the desired number of columns
* @tc.level : Level 0
*/
void wcwidth_0100(void)
{
int result = wcwidth(0);
if (result != 0) {
t_error("%s wcwidth get result is %d are not want 0\n", __func__, result);
}
}
/**
* @tc.name : wcwidth_0200
* @tc.desc : Combining grave
* @tc.level : Level 1
*/
void wcwidth_0200(void)
{
int result = wcwidth(INPUT_VALUE[0]);
if (result != 0) {
t_error("%s wcwidth get result is %d are not want 0\n", __func__, result);
}
}
/**
* @tc.name : wcwidth_0300
* @tc.desc : Combining enclosing circle
* @tc.level : Level 1
*/
void wcwidth_0300(void)
{
int result = wcwidth(INPUT_VALUE[1]);
if (result != 0) {
t_error("%s wcwidth get result is %d are not want 0\n", __func__, result);
}
}
/**
* @tc.name : wcwidth_0400
* @tc.desc : Soft hyphen (SHY)
* @tc.level : Level 1
*/
void wcwidth_0400(void)
{
int result = wcwidth(INPUT_VALUE[2]);
if (result != 1) {
t_error("%s wcwidth get result is %d are not want 1\n", __func__, result);
}
}
/**
* @tc.name : wcwidth_0500
* @tc.desc : Zero width space
* @tc.level : Level 1
*/
void wcwidth_0500(void)
{
int result = wcwidth(INPUT_VALUE[3]);
if (result != 0) {
t_error("%s wcwidth get result is %d are not want 0\n", __func__, result);
}
}
/**
* @tc.name : wcwidth_0600
* @tc.desc : Start of CJK unified block
* @tc.level : Level 1
*/
void wcwidth_0600(void)
{
int result = wcwidth(INPUT_VALUE[4]);
if (result != RESULT_VALUE) {
t_error("%s wcwidth get result is %d are not want 2\n", __func__, result);
}
}
/**
* @tc.name : wcwidth_0700
* @tc.desc : End of CJK unified block
* @tc.level : Level 1
*/
void wcwidth_0700(void)
{
int result = wcwidth(INPUT_VALUE[5]);
if (result != RESULT_VALUE) {
t_error("%s wcwidth get result is %d are not want 2\n", __func__, result);
}
}
/**
* @tc.name : wcwidth_0800
* @tc.desc : Start of CJK extension A block.
* @tc.level : Level 1
*/
void wcwidth_0800(void)
{
int result = wcwidth(INPUT_VALUE[6]);
if (result != RESULT_VALUE) {
t_error("%s wcwidth get result is %d are not want 2\n", __func__, result);
}
}
/**
* @tc.name : wcwidth_0900
* @tc.desc : End of CJK extension A block.
* @tc.level : Level 1
*/
void wcwidth_0900(void)
{
int result = wcwidth(INPUT_VALUE[7]);
if (result != RESULT_VALUE) {
t_error("%s wcwidth get result is %d are not want 2\n", __func__, result);
}
}
/**
* @tc.name : wcwidth_1000
* @tc.desc : Start of CJK extension B block.
* @tc.level : Level 1
*/
void wcwidth_1000(void)
{
int result = wcwidth(INPUT_VALUE[8]);
if (result != RESULT_VALUE) {
t_error("%s wcwidth get result is %d are not want 2\n", __func__, result);
}
}
/**
* @tc.name : wcwidth_1100
* @tc.desc : End of CJK extension B block.
* @tc.level : Level 1
*/
void wcwidth_1100(void)
{
int result = wcwidth(INPUT_VALUE[9]);
if (result != RESULT_VALUE) {
t_error("%s wcwidth get result is %d are not want 2\n", __func__, result);
}
}
/**
* @tc.name : wcwidth_1200
* @tc.desc : Start of block
* @tc.level : Level 1
*/
void wcwidth_1200(void)
{
int result = wcwidth(INPUT_VALUE[10]);
if (result != RESULT_VALUE) {
t_error("%s wcwidth get result is %d are not want 2\n", __func__, result);
}
}
/**
* @tc.name : wcwidth_1300
* @tc.desc : End of defined code points in Unicode 7
* @tc.level : Level 1
*/
void wcwidth_1300(void)
{
int result = wcwidth(INPUT_VALUE[11]);
if (result != RESULT_VALUE) {
t_error("%s wcwidth get result is %d are not want 2\n", __func__, result);
}
}
/**
* @tc.name : wcwidth_1400
* @tc.desc : Korean "crying" emoticon.
* @tc.level : Level 1
*/
void wcwidth_1400(void)
{
int result = wcwidth(L'ㅜ');
if (result != RESULT_VALUE) {
t_error("%s wcwidth get result is %d are not want 2\n", __func__, result);
}
}
/**
* @tc.name : wcwidth_1500
* @tc.desc : Korean "laughing" emoticon..
* @tc.level : Level 1
*/
void wcwidth_1500(void)
{
int result = wcwidth(L'ㅋ');
if (result != RESULT_VALUE) {
t_error("%s wcwidth get result is %d are not want 2\n", __func__, result);
}
}
int main(int argc, char *argv[])
{
wcwidth_0100();
wcwidth_0200();
wcwidth_0300();
wcwidth_0400();
wcwidth_0500();
wcwidth_0600();
wcwidth_0700();
wcwidth_0800();
wcwidth_0900();
wcwidth_1000();
wcwidth_1100();
wcwidth_1200();
wcwidth_1300();
wcwidth_1400();
wcwidth_1500();
return t_status;
}
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
functionalext_supplement_env_test = [ "putenv" ]
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册