Add a hasmntopt() test.
This example came up on the musl mailing list.
Change-Id: I21029c908f22ba9c073845673c3159ada6d9b3ca
diff --git a/tests/mntent_test.cpp b/tests/mntent_test.cpp
index 4b8fc9a..fd69ae1 100644
--- a/tests/mntent_test.cpp
+++ b/tests/mntent_test.cpp
@@ -59,9 +59,7 @@
// indices 1 1
// of keys: 0 5 9 1 4
char mnt_opts[]{"aa=b,a=b,b,bb,c=d"};
- struct mntent ent;
- memset(&ent, 0, sizeof(ent));
- ent.mnt_opts = mnt_opts;
+ struct mntent ent = {.mnt_opts = mnt_opts};
EXPECT_EQ(mnt_opts, hasmntopt(&ent, "aa"));
EXPECT_EQ(mnt_opts + 5, hasmntopt(&ent, "a"));
@@ -71,3 +69,9 @@
EXPECT_EQ(nullptr, hasmntopt(&ent, "d"));
EXPECT_EQ(nullptr, hasmntopt(&ent, "e"));
}
+
+TEST(mntent, hasmntopt_no_suffix_match) {
+ char mnt_opts[]{"noatime"};
+ struct mntent ent = {.mnt_opts = mnt_opts};
+ EXPECT_EQ(nullptr, hasmntopt(&ent, "atime"));
+}