-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
53 lines (47 loc) · 1.07 KB
/
test.cpp
File metadata and controls
53 lines (47 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include<iostream>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
using namespace std;
#include<gtest/gtest.h>
class GlobalTest:public testing::Environment
{
public:
virtual void SetUp()
{
cout<<"RFtest Author:HuiLi"<<endl;
cout<<"Email: huili@ruijie.com.cn"<<endl;
cout<<"2018/7/30"<<endl;
}
virtual void TearDown()
{
}
};
int Abs(int x)
{
return x > 0 ? x : -x;
}
TEST(IsAbs,HandlerTrueReturn)
{
ASSERT_TRUE(Abs(1) == 1) << "Abs(1)=1"; //ASSERT_TRUE期待结果是true,operator<<输出一些自定义的信息
ASSERT_TRUE(Abs(-1) == 1) << "Abs(-1)=1";
ASSERT_FALSE(Abs(-2) == -2); //期待结果是false
ASSERT_EQ(Abs(1),Abs(-1));
ASSERT_NE(Abs(-1),0);
ASSERT_LT(Abs(-1),2);
}
int main(int argc, char *argv[]){
testing::InitGoogleTest(&argc,argv);
testing::Environment *env = new GlobalTest();
testing::AddGlobalTestEnvironment(env);
int ret = RUN_ALL_TESTS();
return ret;
}