26 #include "../server/server.h"
27 #include "../server/sv_rma.h"
28 #include "../ports/system.h"
30 #define MAX_ALLOWED_TIME_TO_ASSEMBLE 30000
31 #define TEST_THEME "forest"
32 #define TEST_ASSEMBLY "nature_large_b"
60 long testAssembly(
const char *source,
const unsigned int numRuns,
const char *mapTheme,
const char *mapAssembly);
72 for (
int i = 0;
i < numRuns;
i++) {
75 Com_Printf(
"%s - assembling map: theme: %s assembly: %s seed: %i\n", source, mapTheme, mapAssembly,
i);
82 Com_Printf(
"%s - error: No tiles placed.\n", source);
83 ADD_FAILURE() << source <<
" - error: No tiles placed (theme: " << mapTheme
84 <<
" assembly: " << mapAssembly <<
" seed: " <<
i <<
").";
87 Com_Printf(
"%s - error: Assembly %s in map theme +%s failed to assemble in a reasonable time with seed %i\n", source, mapTheme, mapAssembly,
i);
88 ADD_FAILURE() <<
"Assembly " << mapTheme <<
"in map theme +" << mapAssembly
89 <<
" failed " << source <<
"using seed: %i " <<
i
90 <<
"(time measured: " << time <<
" ms).";
93 Com_Printf(
"%s - result: seed: %i tiles placed: %i time measured: %li ms\n", source,
i, numPlaced, time);
105 ASSERT_TRUE(numPlaced != 0);
114 ASSERT_TRUE(numPlaced != 0);
120 const char *
self =
"RandomMapAssemblyTest.MassAssemblyTimeout";
121 unsigned const int numRuns = 10;
123 SCOPED_TRACE(
va(
self));
129 const char *
self =
"RandomMapAssemblyTest.MassAssemblyParallel";
130 unsigned const int numRuns = 10;
132 SCOPED_TRACE(
va(
self));
139 const char *
self =
"RandomMapAssemblyTest.MassAssemblySequential";
140 unsigned const int numRuns = 10;
142 SCOPED_TRACE(
va(
self));
149 const char* assNames[][2] = {
153 {
"forest",
"nature_medium_b"},
154 {
"oriental",
"large"},
155 {
"village",
"large"},
159 size_t length =
sizeof(assNames) / (2 *
sizeof(
char*));
160 const char *
self =
"RandomMapAssemblyTest.Seedlists";
161 unsigned const int numRuns = 20;
165 SCOPED_TRACE(
va(
self));
166 for (
int n = 0; n <
length; n++) {
167 timeSum += testAssembly(
self, numRuns, assNames[n][0], assNames[n][1]);
169 Com_Printf(
"%s - result: time total %li ms\n",
self, timeSum);
180 long time, timeSum = 0;
191 const char* mapTheme =
"industrial";
192 const char* asmName =
"medium";
194 mapTheme =
"tropic"; asmName =
"river";
195 mapTheme =
"village"; asmName =
"large";
196 mapTheme =
"desert"; asmName =
"large";
199 ASSERT_TRUE(numPlaced != 0);
202 ASSERT_TRUE(time <
MAX_ALLOWED_TIME_TO_ASSEMBLE) << mapTheme <<
" fails to assemble in a reasonable time with seed " <<
i <<
"(time: " << time <<
" ms)";
204 Com_Printf(
"Seed %i: tiles: %i ms: %li\n",
i, numPlaced, time);
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
#define RMA_HIGHEST_SUPPORTED_SEED
void Com_ParseScripts(bool onlyServer)
void Com_Printf(const char *const fmt,...)
const char * Com_GetRandomMapAssemblyNameForCraft(const char *craftID)
Returns the name of an aircraft or an ufo that is used in the ump files for the random map assembly...
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
#define MAX_ALLOWED_TIME_TO_ASSEMBLE
QGL_EXTERN GLuint GLsizei GLsizei * length
Stores the parsed data of an assembly definition. See *.ump files.
static char mapStr[MAX_TOKEN_CHARS *MAX_TILESTRINGS]
int SV_AssembleMap(const char *mapTheme, const char *assembly, char *asmTiles, char *asmPos, char *entityString, const unsigned int seed, bool print)
cvar_t * sv_rmadisplaythemap
display a character graphic of the tiles placed when RMA2 reaches a dead end.
long testAssembly(const char *source, const unsigned int numRuns, const char *mapTheme, const char *mapAssembly)
cvar_t * Cvar_Set(const char *varName, const char *value,...)
Sets a cvar value.
static char posStr[MAX_TOKEN_CHARS *MAX_TILESTRINGS]
TEST_F(RandomMapAssemblyTest, UMPExtends)
static void SetUpTestCase()
cvar_t * sv_dumpmapassembly
static void TearDownTestCase()
int Sys_Milliseconds(void)