Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit c0ce06f

Browse files
committed
Add a hasmntopt() test.
This example came up on the musl mailing list. Change-Id: I21029c908f22ba9c073845673c3159ada6d9b3ca
1 parent 2e6b77a commit c0ce06f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tests/mntent_test.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ TEST(mntent, hasmntopt) {
5959
// indices 1 1
6060
// of keys: 0 5 9 1 4
6161
char mnt_opts[]{"aa=b,a=b,b,bb,c=d"};
62-
struct mntent ent;
63-
memset(&ent, 0, sizeof(ent));
64-
ent.mnt_opts = mnt_opts;
62+
struct mntent ent = {.mnt_opts = mnt_opts};
6563

6664
EXPECT_EQ(mnt_opts, hasmntopt(&ent, "aa"));
6765
EXPECT_EQ(mnt_opts + 5, hasmntopt(&ent, "a"));
@@ -71,3 +69,9 @@ TEST(mntent, hasmntopt) {
7169
EXPECT_EQ(nullptr, hasmntopt(&ent, "d"));
7270
EXPECT_EQ(nullptr, hasmntopt(&ent, "e"));
7371
}
72+
73+
TEST(mntent, hasmntopt_no_suffix_match) {
74+
char mnt_opts[]{"noatime"};
75+
struct mntent ent = {.mnt_opts = mnt_opts};
76+
EXPECT_EQ(nullptr, hasmntopt(&ent, "atime"));
77+
}

0 commit comments

Comments
 (0)