File: testattal.cpp

package info (click to toggle)
attal 1.0~rc2-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, squeeze, wheezy
  • size: 4,348 kB
  • ctags: 7,428
  • sloc: cpp: 55,101; sh: 267; ansic: 100; makefile: 54
file content (73 lines) | stat: -rw-r--r-- 1,805 bytes parent folder | download
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

#include <QtTest/QtTest>
#include "client/clientInterface.h"
#include "libCommon/attalCommon.h"
#include "libClient/imageTheme.h"
#include "libCommon/define.h"
#include "conf.h"

class TestAttal: public QObject
{
	Q_OBJECT
		private slots:
		void testLord();
		void testPlayer();
		void testGame();
};

void TestAttal::testLord()
{

	useTheme();

	DataTheme.init();
	GenericLord lord;
	GenericLordModel * model = DataTheme.lords.at( 1 );
	lord.setId( 1 );
	lord.reinit();
	QCOMPARE( lord.getCharac( LEVEL ) , 0 );
	QCOMPARE( lord.getOwner() , (GenericPlayer *)0 );
	QCOMPARE( lord.getId() , 1 );
	QCOMPARE( lord.getBaseCharac( MOVE ) , model->getBaseCharac( MOVE ) );
	lord.setBaseCharac( MOVE, lord.getCharac( MAXMOVE ) );
	lord.decreaseBaseCharac( MOVE, 2 );
	QCOMPARE( lord.getBaseCharac( MOVE ) , model->getBaseCharac( MAXMOVE ) -2  );
	lord.endTurn();
	QCOMPARE( lord.getBaseCharac( MOVE ) , model->getBaseCharac( MAXMOVE ) );
	QCOMPARE( ( uint ) lord.getRace() , model->getRace() );
	int count = lord.countUnits();
	Creature * crea = new Creature();
	lord.addCreatures( crea, 10 );
	lord.clearUnits();
	QCOMPARE( lord.countUnits() , 0 );
	lord.setCost( 0, 100);
	QCOMPARE( ( int ) lord.getCost(0) ,100 );
	lord.setVisible( false );
	QCOMPARE( lord.isVisible() ,false );
	GenericCell * cell = new GenericCell();
	lord.setCell( cell );
	QCOMPARE( lord.getCell() ,cell );
	QCOMPARE( cell->getLord() ,(GenericLord *)&lord );
	lord.removeFromGame();
	QCOMPARE( lord.getCell() , (GenericCell * )0 );
	QCOMPARE( cell->getLord() ,(GenericLord *)0 );
	QCOMPARE( lord.hasMachineType( 0 ) , false );
	
	delete crea;
	delete cell;

}

void TestAttal::testPlayer()
{
	GenericPlayer player;
	QCOMPARE( player.isAlive() , true );

}

void TestAttal::testGame()
{
}

QTEST_MAIN(TestAttal)
#include "testattal.moc"