Added some test cases that were failing under new version

This commit is contained in:
Chairn 2022-12-30 01:11:57 +01:00
parent ed58668931
commit 2847d0f6d0
2 changed files with 17 additions and 2 deletions

View file

@ -2831,7 +2831,6 @@ int str_comp_filenames(const char *a, const char *b)
{
if(*a >= '0' && *a <= '9' && *b >= '0' && *b <= '9')
{
result = 0;
do
{
result = *a - *b;
@ -2843,7 +2842,7 @@ int str_comp_filenames(const char *a, const char *b)
return 1;
else if(*b >= '0' && *b <= '9')
return -1;
else
else if(!(!result && *a && *b))
return result;
}

View file

@ -820,6 +820,13 @@ TEST(Str, CompFilename)
EXPECT_GT(str_comp_filenames("b", "A"), 0);
EXPECT_LT(str_comp_filenames("a", "B"), 0);
EXPECT_GT(str_comp_filenames("B", "a"), 0);
EXPECT_EQ(str_comp_filenames("1A", "1a"), 0);
EXPECT_LT(str_comp_filenames("1a", "1B"), 0);
EXPECT_GT(str_comp_filenames("1B", "1a"), 0);
EXPECT_LT(str_comp_filenames("1a", "1b"), 0);
EXPECT_GT(str_comp_filenames("1b", "1a"), 0);
EXPECT_GT(str_comp_filenames("12a", "1B"), 0);
EXPECT_LT(str_comp_filenames("1B", "12a"), 0);
EXPECT_LT(str_comp_filenames("abc", "abcd"), 0);
EXPECT_GT(str_comp_filenames("abcd", "abc"), 0);
EXPECT_LT(str_comp_filenames("abc2", "abcd1"), 0);
@ -829,8 +836,17 @@ TEST(Str, CompFilename)
EXPECT_EQ(str_comp_filenames("file0", "file0"), 0);
EXPECT_LT(str_comp_filenames("file0", "file1"), 0);
EXPECT_GT(str_comp_filenames("file1", "file0"), 0);
EXPECT_LT(str_comp_filenames("file1", "file09"), 0);
EXPECT_GT(str_comp_filenames("file09", "file1"), 0);
EXPECT_LT(str_comp_filenames("file1", "file009"), 0);
EXPECT_GT(str_comp_filenames("file009", "file1"), 0);
EXPECT_LT(str_comp_filenames("file13", "file37"), 0);
EXPECT_GT(str_comp_filenames("file37", "file13"), 0);
EXPECT_LT(str_comp_filenames("file1.ext", "file09.ext"), 0);
EXPECT_GT(str_comp_filenames("file09.ext", "file1.ext"), 0);
EXPECT_LT(str_comp_filenames("file1.ext", "file009.ext"), 0);
EXPECT_GT(str_comp_filenames("file009.ext", "file1.ext"), 0);
EXPECT_EQ(str_comp_filenames("file0.ext", "file0.ext"), 0);
EXPECT_LT(str_comp_filenames("file13.ext", "file37.ext"), 0);
EXPECT_GT(str_comp_filenames("file37.ext", "file13.ext"), 0);
EXPECT_LT(str_comp_filenames("FILE13.EXT", "file37.ext"), 0);