mirror of
https://github.com/RubyMetric/chsrc
synced 2025-08-14 00:20:47 +08:00
Add test for xy_streql_ic()
This commit is contained in:
parent
695ce1072c
commit
1a73a31e06
22
lib/xy.h
22
lib/xy.h
@ -383,24 +383,24 @@ static bool
|
|||||||
xy_streql_ic(const char *str1, const char *str2)
|
xy_streql_ic(const char *str1, const char *str2)
|
||||||
{
|
{
|
||||||
if (NULL == str1 || NULL == str2)
|
if (NULL == str1 || NULL == str2)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t len1 = strlen(str1);
|
size_t len1 = strlen(str1);
|
||||||
size_t len2 = strlen(str2);
|
size_t len2 = strlen(str2);
|
||||||
if (len1 != len2)
|
if (len1 != len2)
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < len1; i++)
|
|
||||||
{
|
|
||||||
if (tolower(str1[i]) != tolower(str2[i]))
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
for (size_t i = 0; i < len1; i++)
|
||||||
|
{
|
||||||
|
if (tolower(str1[i]) != tolower(str2[i]))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* Contributors : Nil Null <nil@null.org>
|
* Contributors : Nil Null <nil@null.org>
|
||||||
* |
|
* |
|
||||||
* Created On : <2023-08-30>
|
* Created On : <2023-08-30>
|
||||||
* Last Modified : <2025-06-20>
|
* Last Modified : <2025-08-08>
|
||||||
*
|
*
|
||||||
* Test xy.h
|
* Test xy.h
|
||||||
* ------------------------------------------------------------*/
|
* ------------------------------------------------------------*/
|
||||||
@ -57,6 +57,11 @@ main (int argc, char const *argv[])
|
|||||||
xy_warn_brkt ("xy.h", "警告", "兰州牛肉面,而非兰州拉面");
|
xy_warn_brkt ("xy.h", "警告", "兰州牛肉面,而非兰州拉面");
|
||||||
xy_error_brkt ("xy.h", "错误", "西安肉丸胡辣汤里没有肉丸");
|
xy_error_brkt ("xy.h", "错误", "西安肉丸胡辣汤里没有肉丸");
|
||||||
|
|
||||||
|
assert (xy_streql ("abc", "abc"));
|
||||||
|
assert (xy_streql_ic ("abc", "abc"));
|
||||||
|
assert (false == xy_streql ("abc", "abC"));
|
||||||
|
assert (true == xy_streql_ic ("abc", "abC"));
|
||||||
|
|
||||||
assert (false == xy_str_end_with ("abcdef", "abcdefg"));
|
assert (false == xy_str_end_with ("abcdef", "abcdefg"));
|
||||||
assert (xy_str_end_with ("abcdef", "def"));
|
assert (xy_str_end_with ("abcdef", "def"));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user