File: RulesTest.cpp

package info (click to toggle)
blobby 1.1.1%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,944 kB
  • sloc: cpp: 22,442; xml: 779; python: 56; makefile: 3
file content (65 lines) | stat: -rw-r--r-- 1,814 bytes parent folder | download | duplicates (2)
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
// #define BOOST_TEST_MODULE GameLogic
#include <boost/test/unit_test.hpp>

#include <iostream>
#include "physfs.h"
#include "GameLogic.h"
#include "DuelMatch.h"
#include "DuelMatchState.h"
#include "GenericIO.h"
#include "FileRead.h"
#include <fstream>

BOOST_AUTO_TEST_SUITE( rules_test )

#define PASSING_TIME() for(int i=0; i < 50; ++i, GL->step());

BOOST_AUTO_TEST_CASE( katja_replay )
{
	BOOST_REQUIRE( PHYSFS_init("C:\\Dokumente und Einstellungen\\Erik\\Eigene Dateien\\Blobby Volley 2\\test\\bin\\debug\\") );
	PHYSFS_setWriteDir(".");
	PHYSFS_addToSearchPath(".", 1);
	
	GameLogic GL = createGameLogic("rules.lua");
	
	// thats the scenario from katja's replay
	PASSING_TIME();
	GL->onBallHitsPlayer(LEFT_PLAYER);
	GL->onBallHitsPlayer(RIGHT_PLAYER);
	PASSING_TIME();
	GL->onBallHitsPlayer(LEFT_PLAYER);
	PASSING_TIME();
	GL->onBallHitsPlayer(LEFT_PLAYER);
	PASSING_TIME();
	
	BOOST_CHECK_EQUAL(GL->getScore(LEFT_PLAYER), 0);
	BOOST_CHECK_EQUAL(GL->getScore(RIGHT_PLAYER), 0);
}

BOOST_AUTO_TEST_CASE( net_squish )
{
	//BOOST_REQUIRE( PHYSFS_init("C:\\Dokumente und Einstellungen\\Erik\\Eigene Dateien\\Blobby Volley 2\\test\\bin\\debug\\") );
	//PHYSFS_setWriteDir(".");
	//PHYSFS_addToSearchPath(".", 1);
	
	std::fstream deb_out ("debug.txt", std::fstream::out);
	
	DuelMatch match(0, 0, false, false);
	
	DuelMatchState mstate;
	FileRead reader ("katjareplay_crash.state");
	std::shared_ptr<GenericIn> gin = GenericIO::createReader(reader);
	
	mstate.deserialize(gin.get());
	
	match.setState(mstate);
	
	for(int i=0; i < 75; ++i)
	{
		match.setPlayersInput( PlayerInput(false, true, true), PlayerInput(true, false, true) );
		match.step();
		deb_out << match.getState().worldState.ballPosition.x << "\t" << 600 - match.getState().worldState.ballPosition.y << "\n";;
	}
}

BOOST_AUTO_TEST_SUITE_END()