Skip to content

Commit fb271dc

Browse files
committed
tests(fnmatch): added additional test cases to cover POSIX classes
Signed-off-by: Spago123 <harun.spago.code@gmail.com>
1 parent 75bab66 commit fb271dc

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

tests/posix/c_lib_ext/src/fnmatch.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
*/
1414
ZTEST(posix_c_lib_ext, test_fnmatch)
1515
{
16-
/* Note: commented out lines indicate known problems to be addressed in #55186 */
17-
1816
zassert_ok(fnmatch("*.c", "foo.c", 0));
1917
zassert_ok(fnmatch("*.c", ".c", 0));
2018
zassert_equal(fnmatch("*.a", "foo.c", 0), FNM_NOMATCH);
@@ -73,11 +71,20 @@ ZTEST(posix_c_lib_ext, test_fnmatch)
7371
zassert_equal(fnmatch("*/*", "a/.b", FNM_PATHNAME | FNM_PERIOD), FNM_NOMATCH);
7472
zassert_ok(fnmatch("*?*/*", "a/.b", FNM_PERIOD));
7573
zassert_ok(fnmatch("*[.]/b", "a./b", FNM_PATHNAME | FNM_PERIOD));
76-
/** Test cases for POSIC classes */
74+
/** Test cases for POSIX classes */
75+
zassert_ok(fnmatch("*[[:alpha:]]", "Z", 0));
76+
zassert_ok(fnmatch("*[[:digit:]]", "7", 0));
77+
zassert_ok(fnmatch("*[[:alnum:]]", "X9", 0));
78+
zassert_ok(fnmatch("*[[:lower:]]", "z", 0));
79+
zassert_ok(fnmatch("*[[:upper:]]", "G", 0));
80+
zassert_ok(fnmatch("*[[:space:]]", " ", 0));
7781
zassert_ok(fnmatch("*[[:alpha:]]/""*[[:alnum:]]", "a/b", FNM_PATHNAME));
7882
zassert_not_equal(fnmatch("*[![:digit:]]*/[![:d-d]", "a/b", FNM_PATHNAME), 0);
7983
zassert_not_equal(fnmatch("*[![:digit:]]*/[[:d-d]", "a/[", FNM_PATHNAME), 0);
8084
zassert_not_equal(fnmatch("*[![:digit:]]*/[![:d-d]", "a/[", FNM_PATHNAME), 0);
85+
zassert_ok(fnmatch("file[0-9].txt", "file3.txt", 0));
86+
zassert_ok(fnmatch("dir/*", "dir/file", FNM_PATHNAME));
87+
zassert_equal(fnmatch("dir/*", "dir/sub/file", FNM_PATHNAME), FNM_NOMATCH);
8188
zassert_ok(fnmatch("a?b", "a.b", FNM_PATHNAME | FNM_PERIOD));
8289
zassert_ok(fnmatch("a*b", "a.b", FNM_PATHNAME | FNM_PERIOD));
8390
zassert_ok(fnmatch("a[.]b", "a.b", FNM_PATHNAME | FNM_PERIOD));

0 commit comments

Comments
 (0)