-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_pwdx.cpp
More file actions
44 lines (37 loc) · 1.15 KB
/
test_pwdx.cpp
File metadata and controls
44 lines (37 loc) · 1.15 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
37
38
39
40
41
42
43
44
#include <gtest/gtest.h>
#include <cfbox/applet_config.hpp>
#if CFBOX_ENABLE_PWDX
#include <cfbox/applets.hpp>
TEST(PwdxTest, HelpAndVersion) {
char a0[] = "pwdx";
char a1[] = "--help";
char* argv[] = {a0, a1, nullptr};
testing::internal::CaptureStdout();
int rc = pwdx_main(2, argv);
std::string out = testing::internal::GetCapturedStdout();
EXPECT_EQ(rc, 0);
EXPECT_NE(out.find("pwdx"), std::string::npos);
}
TEST(PwdxTest, NoArgs) {
char a0[] = "pwdx";
char* argv[] = {a0, nullptr};
testing::internal::CaptureStdout();
testing::internal::CaptureStderr();
int rc = pwdx_main(1, argv);
testing::internal::GetCapturedStdout();
testing::internal::GetCapturedStderr();
EXPECT_EQ(rc, 1);
}
TEST(PwdxTest, SelfCwd) {
char a0[] = "pwdx";
char a1[] = "1";
char* argv[] = {a0, a1, nullptr};
testing::internal::CaptureStdout();
int rc = pwdx_main(2, argv);
std::string out = testing::internal::GetCapturedStdout();
// PID 1 may not exist in all test environments; just verify format if it does
if (rc == 0) {
EXPECT_NE(out.find("1:"), std::string::npos);
}
}
#endif