diff options
Diffstat (limited to 'docs/html/data_tests_8cpp_source.html')
-rw-r--r-- | docs/html/data_tests_8cpp_source.html | 261 |
1 files changed, 261 insertions, 0 deletions
diff --git a/docs/html/data_tests_8cpp_source.html b/docs/html/data_tests_8cpp_source.html new file mode 100644 index 0000000..163697e --- /dev/null +++ b/docs/html/data_tests_8cpp_source.html @@ -0,0 +1,261 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> +<title>Rally X: tests/dataTests.cpp Source File</title> + +<link href="tabs.css" rel="stylesheet" type="text/css"/> +<link href="doxygen.css" rel="stylesheet" type="text/css" /> + +<link href="search/search.css" rel="stylesheet" type="text/css"/> +<script type="text/javascript" src="jquery.js"></script> +<script type="text/javascript" src="search/search.js"></script> +<script type="text/javascript"> + $(document).ready(function() { searchBox.OnSelectItem(0); }); +</script> + +</head> +<body> +<div id="top"><!-- do not remove this div! --> + + +<div id="titlearea"> +<table cellspacing="0" cellpadding="0"> + <tbody> + <tr style="height: 56px;"> + + <td id="projectlogo"><img alt="Logo" src="car.PNG"/></td> + + + <td style="padding-left: 0.5em;"> + <div id="projectname">Rally X + + </div> + <div id="projectbrief">ELEN3009 Project by Justin Wernick and David Schneider</div> + </td> + + + + </tr> + </tbody> +</table> +</div> + +<!-- Generated by Doxygen 1.7.5.1 --> +<script type="text/javascript"> +var searchBox = new SearchBox("searchBox", "search",false,'Search'); +</script> + <div id="navrow1" class="tabs"> + <ul class="tablist"> + <li><a href="index.html"><span>Main Page</span></a></li> + <li><a href="annotated.html"><span>Classes</span></a></li> + <li class="current"><a href="files.html"><span>Files</span></a></li> + <li> + <div id="MSearchBox" class="MSearchBoxInactive"> + <span class="left"> + <img id="MSearchSelect" src="search/mag_sel.png" + onmouseover="return searchBox.OnSearchSelectShow()" + onmouseout="return searchBox.OnSearchSelectHide()" + alt=""/> + <input type="text" id="MSearchField" value="Search" accesskey="S" + onfocus="searchBox.OnSearchFieldFocus(true)" + onblur="searchBox.OnSearchFieldFocus(false)" + onkeyup="searchBox.OnSearchFieldChange(event)"/> + </span><span class="right"> + <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> + </span> + </div> + </li> + </ul> + </div> + <div id="navrow2" class="tabs2"> + <ul class="tablist"> + <li><a href="files.html"><span>File List</span></a></li> + <li><a href="globals.html"><span>File Members</span></a></li> + </ul> + </div> +<div class="header"> + <div class="headertitle"> +<div class="title">tests/dataTests.cpp</div> </div> +</div> +<div class="contents"> +<a href="data_tests_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 +<a name="l00017"></a>00017 <span class="preprocessor">#include <cstdio></span> +<a name="l00018"></a>00018 <span class="preprocessor">#include <fstream></span> +<a name="l00019"></a>00019 <span class="keyword">using namespace </span>std; +<a name="l00020"></a>00020 +<a name="l00021"></a>00021 <span class="preprocessor">#include <gtest/gtest.h></span> +<a name="l00022"></a>00022 +<a name="l00023"></a>00023 <span class="preprocessor">#include "../source/data/Config.h"</span> +<a name="l00024"></a>00024 <span class="preprocessor">#include "../source/data/LevelReader.h"</span> +<a name="l00025"></a>00025 <span class="preprocessor">#include "../source/logic/PlayerCar.h"</span> +<a name="l00026"></a>00026 <span class="preprocessor">#include "../source/logic/EnemyCar.h"</span> +<a name="l00027"></a>00027 <span class="preprocessor">#include "../source/logic/Checkpoint.h"</span> +<a name="l00028"></a>00028 <span class="preprocessor">#include "../source/logic/Rock.h"</span> +<a name="l00029"></a>00029 <span class="preprocessor">#include "../source/logic/Smokescreen.h"</span> +<a name="l00030"></a>00030 <span class="preprocessor">#include "../source/logic/Maze.h"</span> +<a name="l00031"></a>00031 +<a name="l00035"></a><a class="code" href="data_tests_8cpp.html#a7612e068db66f415f3b230260450eba8">00035</a> <a class="code" href="data_tests_8cpp.html#a7612e068db66f415f3b230260450eba8" title="Tests that a normal complete config file can be read.">TEST</a>(<a class="code" href="class_config.html" title="Object for handling user settings loaded from a file.">Config</a>, readsSettingsCorrectly) +<a name="l00036"></a>00036 { +<a name="l00037"></a>00037 <span class="keywordtype">string</span> testFilepath = <span class="stringliteral">"testConfig.txt"</span>; +<a name="l00038"></a>00038 ofstream testFile(testFilepath.c_str()); +<a name="l00039"></a>00039 +<a name="l00040"></a>00040 testFile << <span class="stringliteral">"screen_width=123"</span> << endl; +<a name="l00041"></a>00041 testFile << <span class="stringliteral">"screen_height=345"</span> << endl; +<a name="l00042"></a>00042 testFile << <span class="stringliteral">"fullscreen=true"</span> << endl; +<a name="l00043"></a>00043 +<a name="l00044"></a>00044 testFile.close(); +<a name="l00045"></a>00045 +<a name="l00046"></a>00046 <a class="code" href="class_config.html" title="Object for handling user settings loaded from a file.">Config</a> testConfig(testFilepath); +<a name="l00047"></a>00047 +<a name="l00048"></a>00048 EXPECT_EQ((<span class="keywordtype">unsigned</span>)(123), testConfig.<a class="code" href="class_config.html#a3bb73797396d2d5ba8c9956730dfc4db" title="Function for accessing the screen width setting in pixels.">screenWidth</a>()); +<a name="l00049"></a>00049 EXPECT_EQ((<span class="keywordtype">unsigned</span>)(345), testConfig.<a class="code" href="class_config.html#a53d63c52aa51b5231b9ea8e412086773" title="Function for accessing the screen height setting in pixels.">screenHeight</a>()); +<a name="l00050"></a>00050 EXPECT_TRUE(testConfig.<a class="code" href="class_config.html#a8a401add779f2b74732ade9e515bf0cd" title="Function for accessing whether the game should be displayed in fullscreen or windowed mode...">fullscreen</a>()); +<a name="l00051"></a>00051 +<a name="l00052"></a>00052 <span class="keyword">remove</span>(testFilepath.c_str()); +<a name="l00053"></a>00053 } +<a name="l00054"></a>00054 +<a name="l00058"></a><a class="code" href="data_tests_8cpp.html#a2159abeac0546de95bbdd68b1e10c56c">00058</a> <a class="code" href="data_tests_8cpp.html#a7612e068db66f415f3b230260450eba8" title="Tests that a normal complete config file can be read.">TEST</a>(<a class="code" href="class_config.html" title="Object for handling user settings loaded from a file.">Config</a>, createsFileIfNeeded) +<a name="l00059"></a>00059 { +<a name="l00060"></a>00060 <span class="keywordtype">string</span> testFilepath = <span class="stringliteral">"testConfig.txt"</span>; +<a name="l00061"></a>00061 <a class="code" href="class_config.html" title="Object for handling user settings loaded from a file.">Config</a> testConfig(testFilepath); +<a name="l00062"></a>00062 +<a name="l00063"></a>00063 ifstream testFile(testFilepath.c_str()); +<a name="l00064"></a>00064 EXPECT_TRUE(testFile); +<a name="l00065"></a>00065 testFile.close(); +<a name="l00066"></a>00066 +<a name="l00067"></a>00067 <span class="comment">//test for default values</span> +<a name="l00068"></a>00068 EXPECT_EQ((<span class="keywordtype">unsigned</span>)(800), testConfig.<a class="code" href="class_config.html#a3bb73797396d2d5ba8c9956730dfc4db" title="Function for accessing the screen width setting in pixels.">screenWidth</a>()); +<a name="l00069"></a>00069 EXPECT_EQ((<span class="keywordtype">unsigned</span>)(600), testConfig.<a class="code" href="class_config.html#a53d63c52aa51b5231b9ea8e412086773" title="Function for accessing the screen height setting in pixels.">screenHeight</a>()); +<a name="l00070"></a>00070 EXPECT_FALSE(testConfig.<a class="code" href="class_config.html#a8a401add779f2b74732ade9e515bf0cd" title="Function for accessing whether the game should be displayed in fullscreen or windowed mode...">fullscreen</a>()); +<a name="l00071"></a>00071 +<a name="l00072"></a>00072 <span class="keyword">remove</span>(testFilepath.c_str()); +<a name="l00073"></a>00073 } +<a name="l00074"></a>00074 +<a name="l00078"></a><a class="code" href="data_tests_8cpp.html#a49403434f62b3318444eff742d2b2231">00078</a> <a class="code" href="data_tests_8cpp.html#a7612e068db66f415f3b230260450eba8" title="Tests that a normal complete config file can be read.">TEST</a>(<a class="code" href="class_config.html" title="Object for handling user settings loaded from a file.">Config</a>, incompleteFileFilled) +<a name="l00079"></a>00079 { +<a name="l00080"></a>00080 <span class="keywordtype">string</span> testFilepath = <span class="stringliteral">"testConfig.txt"</span>; +<a name="l00081"></a>00081 ofstream testFile(testFilepath.c_str()); +<a name="l00082"></a>00082 +<a name="l00083"></a>00083 testFile << <span class="stringliteral">"screen_height=345"</span> << endl; +<a name="l00084"></a>00084 +<a name="l00085"></a>00085 testFile.close(); +<a name="l00086"></a>00086 +<a name="l00087"></a>00087 <a class="code" href="class_config.html" title="Object for handling user settings loaded from a file.">Config</a> testConfig(testFilepath); +<a name="l00088"></a>00088 +<a name="l00089"></a>00089 EXPECT_EQ((<span class="keywordtype">unsigned</span>)(800), testConfig.<a class="code" href="class_config.html#a3bb73797396d2d5ba8c9956730dfc4db" title="Function for accessing the screen width setting in pixels.">screenWidth</a>()); +<a name="l00090"></a>00090 EXPECT_EQ((<span class="keywordtype">unsigned</span>)(345), testConfig.<a class="code" href="class_config.html#a53d63c52aa51b5231b9ea8e412086773" title="Function for accessing the screen height setting in pixels.">screenHeight</a>()); +<a name="l00091"></a>00091 EXPECT_FALSE(testConfig.<a class="code" href="class_config.html#a8a401add779f2b74732ade9e515bf0cd" title="Function for accessing whether the game should be displayed in fullscreen or windowed mode...">fullscreen</a>()); +<a name="l00092"></a>00092 +<a name="l00093"></a>00093 <span class="keyword">remove</span>(testFilepath.c_str()); +<a name="l00094"></a>00094 } +<a name="l00095"></a>00095 +<a name="l00099"></a><a class="code" href="data_tests_8cpp.html#afc4fdfbf4ea1ef87d266b9b67cc665d1">00099</a> <a class="code" href="data_tests_8cpp.html#a7612e068db66f415f3b230260450eba8" title="Tests that a normal complete config file can be read.">TEST</a>(<a class="code" href="class_level_reader.html" title="Reads the game objects from a text file and calls relevant constructors.">LevelReader</a>, readsFileInfoObjects) +<a name="l00100"></a>00100 { +<a name="l00101"></a>00101 <span class="keywordtype">string</span> testFilepath = <span class="stringliteral">"testMaze.lvl"</span>; +<a name="l00102"></a>00102 ofstream testFile(testFilepath.c_str()); +<a name="l00103"></a>00103 +<a name="l00104"></a>00104 testFile << <span class="stringliteral">" P X "</span> << endl; +<a name="l00105"></a>00105 testFile << <span class="stringliteral">" "</span> << endl; +<a name="l00106"></a>00106 testFile << <span class="stringliteral">" @ "</span> << endl; +<a name="l00107"></a>00107 testFile << <span class="stringliteral">" X"</span> << endl; +<a name="l00108"></a>00108 testFile << <span class="stringliteral">"## "</span> << endl; +<a name="l00109"></a>00109 testFile << <span class="stringliteral">" P "</span> << endl; +<a name="l00110"></a>00110 testFile << <span class="stringliteral">" O "</span> << endl; +<a name="l00111"></a>00111 +<a name="l00112"></a>00112 testFile.close(); +<a name="l00113"></a>00113 +<a name="l00114"></a>00114 <a class="code" href="class_level_reader.html" title="Reads the game objects from a text file and calls relevant constructors.">LevelReader</a> testReader(testFilepath); +<a name="l00115"></a>00115 <a class="code" href="class_maze.html" title="A rectangular 2D boolean array, representing where cars can drive and where they cannot.">Maze</a> maze; +<a name="l00116"></a>00116 list<PlayerCar> players; +<a name="l00117"></a>00117 list<EnemyCar> enemies; +<a name="l00118"></a>00118 list<Checkpoint> checkpoints; +<a name="l00119"></a>00119 list<Rock> rocks; +<a name="l00120"></a>00120 testReader.<a class="code" href="class_level_reader.html#a27277149f3270e040c8ffeadbca79758" title="Function to read the chosen file into the data structures used in the game.">readLevel</a>(maze, players, enemies, checkpoints, rocks); +<a name="l00121"></a>00121 +<a name="l00122"></a>00122 list<PlayerCar> expectedPlayers; +<a name="l00123"></a>00123 list<EnemyCar> expectedEnemies; +<a name="l00124"></a>00124 list<Checkpoint> expectedCheckpoints; +<a name="l00125"></a>00125 list<Rock> expectedRocks; +<a name="l00126"></a>00126 +<a name="l00127"></a>00127 expectedPlayers.push_back(<a class="code" href="class_player_car.html" title="A GameObject that is controlled by the player.">PlayerCar</a>(3,2)); +<a name="l00128"></a>00128 expectedEnemies.push_back(<a class="code" href="class_enemy_car.html" title="GameObject that chases the player around the maze.">EnemyCar</a>(3,0)); +<a name="l00129"></a>00129 expectedEnemies.push_back(<a class="code" href="class_enemy_car.html" title="GameObject that chases the player around the maze.">EnemyCar</a>(5,3)); +<a name="l00130"></a>00130 expectedCheckpoints.push_back(<a class="code" href="class_checkpoint.html" title="GameObject that the player needs to pick up by driving over.">Checkpoint</a>(2,0)); +<a name="l00131"></a>00131 expectedCheckpoints.push_back(<a class="code" href="class_checkpoint.html" title="GameObject that the player needs to pick up by driving over.">Checkpoint</a>(3,5)); +<a name="l00132"></a>00132 expectedRocks.push_back(<a class="code" href="class_rock.html" title="A game object that acts as an obstacle to the player.">Rock</a>(2,6)); +<a name="l00133"></a>00133 +<a name="l00134"></a>00134 <span class="comment">//eqality operator was not implemented for the GameObject class or its subclasses</span> +<a name="l00135"></a>00135 <span class="comment">//because it would not be meaningful. Two objects with the same position, type, and facing</span> +<a name="l00136"></a>00136 <span class="comment">//are still two different objects.</span> +<a name="l00137"></a>00137 <span class="comment">//iterators were used because the list type does not have an 'at' function.</span> +<a name="l00138"></a>00138 list<PlayerCar>::const_iterator playIter = players.begin(); +<a name="l00139"></a>00139 EXPECT_FLOAT_EQ(playIter->x(), 3); +<a name="l00140"></a>00140 EXPECT_FLOAT_EQ(playIter->y(), 2); +<a name="l00141"></a>00141 ++playIter; +<a name="l00142"></a>00142 EXPECT_EQ(playIter, players.end()); +<a name="l00143"></a>00143 +<a name="l00144"></a>00144 list<EnemyCar>::const_iterator enemyIter = enemies.begin(); +<a name="l00145"></a>00145 EXPECT_FLOAT_EQ(enemyIter->x(), 3); +<a name="l00146"></a>00146 EXPECT_FLOAT_EQ(enemyIter->y(), 0); +<a name="l00147"></a>00147 ++enemyIter; +<a name="l00148"></a>00148 EXPECT_FLOAT_EQ(enemyIter->x(), 5); +<a name="l00149"></a>00149 EXPECT_FLOAT_EQ(enemyIter->y(), 3); +<a name="l00150"></a>00150 ++enemyIter; +<a name="l00151"></a>00151 EXPECT_EQ(enemyIter, enemies.end()); +<a name="l00152"></a>00152 +<a name="l00153"></a>00153 list<Checkpoint>::const_iterator checkIter = checkpoints.begin(); +<a name="l00154"></a>00154 EXPECT_FLOAT_EQ(checkIter->x(), 1); +<a name="l00155"></a>00155 EXPECT_FLOAT_EQ(checkIter->y(), 0); +<a name="l00156"></a>00156 ++checkIter; +<a name="l00157"></a>00157 EXPECT_FLOAT_EQ(checkIter->x(), 3); +<a name="l00158"></a>00158 EXPECT_FLOAT_EQ(checkIter->y(), 5); +<a name="l00159"></a>00159 ++checkIter; +<a name="l00160"></a>00160 EXPECT_EQ(checkIter, checkpoints.end()); +<a name="l00161"></a>00161 +<a name="l00162"></a>00162 list<Rock>::const_iterator rockIter = rocks.begin(); +<a name="l00163"></a>00163 EXPECT_FLOAT_EQ(rockIter->x(), 2); +<a name="l00164"></a>00164 EXPECT_FLOAT_EQ(rockIter->y(), 6); +<a name="l00165"></a>00165 ++rockIter; +<a name="l00166"></a>00166 EXPECT_EQ(rockIter, rocks.end()); +<a name="l00167"></a>00167 +<a name="l00168"></a>00168 <span class="keyword">remove</span>(testFilepath.c_str()); +<a name="l00169"></a>00169 } +<a name="l00170"></a>00170 +<a name="l00174"></a><a class="code" href="data_tests_8cpp.html#a63083af852f9dfa8036f327f6fa84328">00174</a> <a class="code" href="data_tests_8cpp.html#a7612e068db66f415f3b230260450eba8" title="Tests that a normal complete config file can be read.">TEST</a>(<a class="code" href="class_level_reader.html" title="Reads the game objects from a text file and calls relevant constructors.">LevelReader</a>, throwsExceptionOnBadFilename) +<a name="l00175"></a>00175 { +<a name="l00176"></a>00176 <span class="keywordtype">string</span> testFilepath = <span class="stringliteral">"testLevel.lvl"</span>; +<a name="l00177"></a>00177 <a class="code" href="class_level_reader.html" title="Reads the game objects from a text file and calls relevant constructors.">LevelReader</a> testReader(testFilepath); +<a name="l00178"></a>00178 <a class="code" href="class_maze.html" title="A rectangular 2D boolean array, representing where cars can drive and where they cannot.">Maze</a> maze; +<a name="l00179"></a>00179 list<PlayerCar> players; +<a name="l00180"></a>00180 list<EnemyCar> enemies; +<a name="l00181"></a>00181 list<Checkpoint> checkpoints; +<a name="l00182"></a>00182 list<Rock> rocks; +<a name="l00183"></a>00183 EXPECT_ANY_THROW(testReader.<a class="code" href="class_level_reader.html#a27277149f3270e040c8ffeadbca79758" title="Function to read the chosen file into the data structures used in the game.">readLevel</a>(maze, players, enemies, checkpoints, rocks)); +<a name="l00184"></a>00184 } +</pre></div></div> +</div> +<!-- window showing the filter options --> +<div id="MSearchSelectWindow" + onmouseover="return searchBox.OnSearchSelectShow()" + onmouseout="return searchBox.OnSearchSelectHide()" + onkeydown="return searchBox.OnSearchSelectKey(event)"> +<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerator</a></div> + +<!-- iframe showing the search results (closed by default) --> +<div id="MSearchResultsWindow"> +<iframe src="javascript:void(0)" frameborder="0" + name="MSearchResults" id="MSearchResults"> +</iframe> +</div> + + + +<hr class="footer"/><address class="footer"><small> +Generated on Wed Oct 5 2011 20:08:31 for Rally X by  <a href="http://www.doxygen.org/index.html"> +<img class="footer" src="doxygen.png" alt="doxygen"/> +</a> 1.7.5.1 +</small></address> + +</body> +</html> |