-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathfixture.cpp
70 lines (62 loc) · 1.48 KB
/
fixture.cpp
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//======================================================================
//-----------------------------------------------------------------------
/**
* @file fixture.cpp
* @brief fixture sample
*
* @author t.shirayanagi
* @par copyright
* Copyright (C) 2014-2020, Takazumi Shirayanagi\n
* This software is released under the new BSD License,
* see LICENSE
*/
//-----------------------------------------------------------------------
//======================================================================
#include "../include/iutest.hpp"
/* ---------------------------------------------------
* テストフィクスチャの利用
*//*--------------------------------------------------*/
class TestFixed : public ::iutest::Test
{
protected:
static int x;
public:
virtual void SetUp()
{
++x;
}
static void SetUpTestSuite()
{
x = 0;
}
};
int TestFixed::x = -1;
IUTEST_F(TestFixed, Test1)
{
IUTEST_ASSERT_EQ(1, x);
}
IUTEST_F(TestFixed, Test2)
{
IUTEST_ASSERT_EQ(2, x);
}
typedef TestFixed TestFixed2;
struct Point
{
int x, y;
bool operator == (const Point& rhs) const { return x==rhs.x && y==rhs.y; }
};
IUTEST_F(TestFixed2, Test1)
{
IUTEST_ASSERT_EQ(1, x);
{
Point a = {0, 0};
Point b = {0, 0};
IUTEST_EXPECT_EQ(a, b); // operator == があれば可能.
}
}
IUTEST_F(TestFixed2, Test2)
{
IUTEST_ASSERT_EQ(2, x);
IUTEST_EXPECT_EQ(2, x);
IUTEST_INFORM_EQ(2, x);
}