-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_mountpoint.cpp
More file actions
36 lines (29 loc) · 1.07 KB
/
test_mountpoint.cpp
File metadata and controls
36 lines (29 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <cfbox/applets.hpp>
#include <cfbox/applet_config.hpp>
#include <gtest/gtest.h>
#include "test_capture.hpp"
#if CFBOX_ENABLE_MOUNTPOINT
TEST(MountpointTest, RootIsMountpoint) {
char a0[] = "mountpoint", a1[] = "/";
char* argv[] = {a0, a1, nullptr};
EXPECT_EQ(mountpoint_main(2, argv), 0);
}
TEST(MountpointTest, NonexistentPath) {
char a0[] = "mountpoint", a1[] = "/nonexistent_xyz_12345";
char* argv[] = {a0, a1, nullptr};
EXPECT_NE(mountpoint_main(2, argv), 0);
}
TEST(MountpointTest, QuietMode) {
char a0[] = "mountpoint", a1[] = "-q", a2[] = "/";
char* argv[] = {a0, a1, a2, nullptr};
auto out = cfbox::test::capture_stdout([&] { return mountpoint_main(3, argv); });
EXPECT_EQ(mountpoint_main(3, argv), 0);
EXPECT_TRUE(out.empty());
}
TEST(MountpointTest, Help) {
char a0[] = "mountpoint", a1[] = "--help";
char* argv[] = {a0, a1, nullptr};
auto out = cfbox::test::capture_stdout([&] { return mountpoint_main(2, argv); });
EXPECT_NE(out.find("mountpoint"), std::string::npos);
}
#endif // CFBOX_ENABLE_MOUNTPOINT