-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_top.cpp
More file actions
32 lines (27 loc) · 820 Bytes
/
Copy pathtest_top.cpp
File metadata and controls
32 lines (27 loc) · 820 Bytes
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
#include <gtest/gtest.h>
#include <cfbox/applet_config.hpp>
#if CFBOX_ENABLE_TOP
#include <cfbox/applets.hpp>
TEST(TopTest, HelpAndVersion) {
char a0[] = "top";
char a1[] = "--help";
char* argv[] = {a0, a1, nullptr};
testing::internal::CaptureStdout();
int rc = top_main(2, argv);
std::string out = testing::internal::GetCapturedStdout();
EXPECT_EQ(rc, 0);
EXPECT_NE(out.find("top"), std::string::npos);
}
TEST(TopTest, BatchMode) {
char a0[] = "top";
char a1[] = "-b";
char a2[] = "-n";
char a3[] = "1";
char* argv[] = {a0, a1, a2, a3, nullptr};
testing::internal::CaptureStdout();
int rc = top_main(4, argv);
std::string out = testing::internal::GetCapturedStdout();
EXPECT_EQ(rc, 0);
EXPECT_NE(out.find("PID"), std::string::npos);
}
#endif