File: BaseTest.h

package info (click to toggle)
pinball 0.3.20201218-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 8,452 kB
  • sloc: cpp: 15,230; makefile: 840; sh: 381; xml: 24
file content (113 lines) | stat: -rw-r--r-- 2,759 bytes parent folder | download | duplicates (9)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/***************************************************************************
                          BaseTest.h  -  description
                             -------------------
    begin                : Sun Aug 25 2002
    copyright            : (C) 2002 by Henrik Enqvist
    email                : henqvist@excite.com
 ***************************************************************************/

/****************************************************************************
 * Unit testing
 ***************************************************************************/

#ifndef BASETEST_H
#define BASETEST_H

#if EM_UNIT_TEST

#include "EMath.h"
#include "Shape3D.h"
#include "Polygon.h"

#include <cppunit/TestFixture.h>
#include <cppunit/Test.h>
#include <cppunit/TestSuite.h>
#include <cppunit/TestCaller.h>
#include <cppunit/extensions/HelperMacros.h>

class EMathTest : public CppUnit::TestFixture {
 public:
  void setUp() {
  }

  void tearDown() {
  }

  void testTrigonometry() {
  }

  void testInterpolation() {
  }
 
	CPPUNIT_TEST_SUITE(EMathTest);

	CPPUNIT_TEST(testTrigonometry);
	CPPUNIT_TEST(testInterpolation);
	
	CPPUNIT_TEST_SUITE_END();
};

class ShapeTest : public CppUnit::TestFixture {
 private:
	Shape3D * shape;
	Polygon3D * poly;
 public:
  void setUp() {
		shape = new Shape3D();
		shape->add(0,0,0, 0,0,0,0, 0,0);
		shape->add(0,0,0, 0,0,0,0, 0,0);
		shape->add(0,0,0, 0,0,0,0, 0,0);
		shape->add(0,0,0, 0,0,0,0, 0,0);
		shape->add(0,0,0, 0,0,0,0, 0,0);
		shape->add(0,0,0, 0,0,0,0, 0,0);
		poly = new Polygon3D(shape);
		poly->add(1);
		poly->add(2);
		poly->add(4);
		poly->add(3);
  }

  void tearDown() {
		delete poly;
		delete shape;
  }

	void testIndex() {
		CPPUNIT_ASSERT(poly->getIndex(0) == 1);
		CPPUNIT_ASSERT(poly->getIndex(1) == 2);
		CPPUNIT_ASSERT(poly->getIndex(2) == 4);
		CPPUNIT_ASSERT(poly->getIndex(3) == 3);
	}

	void testIncludes() {
		CPPUNIT_ASSERT(poly->includes(0) == -1);
		CPPUNIT_ASSERT(poly->includes(1) == 0);
		CPPUNIT_ASSERT(poly->includes(2) == 1);
		CPPUNIT_ASSERT(poly->includes(3) == 3);
		CPPUNIT_ASSERT(poly->includes(4) == 2);
		CPPUNIT_ASSERT(poly->includes(5) == -1);
	}

	void testConnected() {
		CPPUNIT_ASSERT(poly->connected(1,2) == true);
		CPPUNIT_ASSERT(poly->connected(2,1) == true);
		CPPUNIT_ASSERT(poly->connected(2,4) == true);
		CPPUNIT_ASSERT(poly->connected(4,3) == true);
		CPPUNIT_ASSERT(poly->connected(1,3) == true);
		CPPUNIT_ASSERT(poly->connected(1,0) == false);
		CPPUNIT_ASSERT(poly->connected(0,2) == false);
		CPPUNIT_ASSERT(poly->connected(1,4) == false);
	}

	CPPUNIT_TEST_SUITE(ShapeTest);

	CPPUNIT_TEST(testIndex);
	CPPUNIT_TEST(testIncludes);
	CPPUNIT_TEST(testConnected);
	
	CPPUNIT_TEST_SUITE_END();
};

#endif //EM_UNIT_TEST

#endif // EMATH_H