Skip to content

Commit 00de0de

Browse files
committed
posix: c_lib_ext: fnmatch: added test coverage cases to cover POSIX clases
Added tests for isprint, ispunct, islower and other posix classes Signed-off-by: Harun Spago <harun.spago.code@gmail.com>
1 parent e0eb14a commit 00de0de

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

tests/posix/c_lib_ext/src/fnmatch.c

Lines changed: 16 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,26 @@ 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-
/* zassert_ok(fnmatch("*[[:alpha:]]/""*[[:alnum:]]", "a/b", FNM_PATHNAME)); */
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));
81+
zassert_ok(fnmatch("*[[:alpha:]]/"
82+
"*[[:alnum:]]",
83+
"a/b", FNM_PATHNAME));
7784
zassert_not_equal(fnmatch("*[![:digit:]]*/[![:d-d]", "a/b", FNM_PATHNAME), 0);
7885
zassert_not_equal(fnmatch("*[![:digit:]]*/[[:d-d]", "a/[", FNM_PATHNAME), 0);
7986
zassert_not_equal(fnmatch("*[![:digit:]]*/[![:d-d]", "a/[", FNM_PATHNAME), 0);
87+
zassert_ok(fnmatch("file[0-9].txt", "file3.txt", 0));
88+
zassert_ok(fnmatch("dir/*", "dir/file", FNM_PATHNAME));
89+
zassert_equal(fnmatch("dir/*", "dir/sub/file", FNM_PATHNAME), FNM_NOMATCH);
8090
zassert_ok(fnmatch("a?b", "a.b", FNM_PATHNAME | FNM_PERIOD));
8191
zassert_ok(fnmatch("a*b", "a.b", FNM_PATHNAME | FNM_PERIOD));
8292
zassert_ok(fnmatch("a[.]b", "a.b", FNM_PATHNAME | FNM_PERIOD));
93+
zassert_ok(fnmatch("*[[:alpha:]]", "Z", 0));
94+
zassert_equal(fnmatch("[[:foobarbaz:]]", "Z", 0), FNM_NOMATCH);
95+
zassert_ok(fnmatch("*[[:alpha:]]", "Z", 0));
8396
}

0 commit comments

Comments
 (0)