test: modernize test-dirent-util

Follow-up for 6a57d86bf9
This commit is contained in:
Luca Boccassi
2024-04-26 17:09:04 +01:00
parent 7d967aacce
commit e86e9ebf60

View File

@@ -74,28 +74,28 @@ TEST (test_dirent_is_file) {
}
rewinddir(dir);
while ((de_reg = readdir_ensure_type(dir)) != NULL)
if (strcmp(de_reg->d_name, "test.txt") == 0)
while ((de_reg = readdir_ensure_type(dir)))
if (streq(de_reg->d_name, "test.txt"))
break;
rewinddir(dir);
while ((de_lnk = readdir_ensure_type(dir)) != NULL)
if (strcmp(de_lnk->d_name, "test_link") == 0)
while ((de_lnk = readdir_ensure_type(dir)))
if (streq(de_lnk->d_name, "test_link"))
break;
rewinddir(dir);
while ((de_dot = readdir_ensure_type(dir)) != NULL)
if (strcmp(de_dot->d_name, ".hidden_file") == 0)
while ((de_dot = readdir_ensure_type(dir)))
if (streq(de_dot->d_name, ".hidden_file"))
break;
rewinddir(dir);
while ((de_bak = readdir(dir)) != NULL)
if (strcmp(de_bak->d_name, "test.bak") == 0)
while ((de_bak = readdir(dir)))
if (streq(de_bak->d_name, "test.bak"))
break;
rewinddir(dir);
while ((de_tilda = readdir(dir)) != NULL)
if (strcmp(de_tilda->d_name, "test~") == 0)
while ((de_tilda = readdir(dir)))
if (streq(de_tilda->d_name, "test~"))
break;
/* Test when d_type is DT_REG, DT_LNK, or DT_UNKNOWN */
@@ -154,29 +154,29 @@ TEST (test_dirent_is_file_with_suffix) {
}
rewinddir(dir);
while ((de_reg = readdir_ensure_type(dir)) != NULL)
if (strcmp(de_reg->d_name, "test.txt") == 0)
while ((de_reg = readdir_ensure_type(dir)))
if (streq(de_reg->d_name, "test.txt"))
break;
rewinddir(dir);
while ((de_lnk = readdir_ensure_type(dir)) != NULL)
if (strcmp(de_lnk->d_name, "test_link") == 0)
while ((de_lnk = readdir_ensure_type(dir)))
if (streq(de_lnk->d_name, "test_link"))
break;
rewinddir(dir);
while ((de_dot = readdir_ensure_type(dir)) != NULL)
if (strcmp(de_dot->d_name, ".hidden_file") == 0)
while ((de_dot = readdir_ensure_type(dir)))
if (streq(de_dot->d_name, ".hidden_file"))
break;
rewinddir(dir);
while ((de_dotdot = readdir(dir)) != NULL)
if (strcmp(de_dotdot->d_name, "..dotdot") == 0)
while ((de_dotdot = readdir(dir)))
if (streq(de_dotdot->d_name, "..dotdot"))
break;
if (chr) {
rewinddir(dir);
while ((de_chr = readdir(dir)) != NULL)
if (strcmp(de_chr->d_name, "test_chr") == 0)
while ((de_chr = readdir(dir)))
if (streq(de_chr->d_name, "test_chr"))
break;
/* Test when d_type is not DT_REG, DT_LNK, or DT_UNKNOWN */