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;
129 const char *self =
"RandomMapAssemblyTest.MassAssemblyParallel";
130 unsigned const int numRuns = 10;
139 const char *self =
"RandomMapAssemblyTest.MassAssemblySequential";
140 unsigned const int numRuns = 10;
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;
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);
Stores the parsed data of an assembly definition. See *.ump files.
static void TearDownTestCase()
long testAssembly(const char *source, const unsigned int numRuns, const char *mapTheme, const char *mapAssembly)
static void SetUpTestCase()
void Com_Printf(const char *const fmt,...)
cvar_t * Cvar_Set(const char *varName, const char *value,...)
Sets a cvar value.
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
QGL_EXTERN GLuint GLsizei GLsizei * length
void Com_ParseScripts(bool onlyServer)
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.
Main server include file.
cvar_t * sv_rmadisplaythemap
display a character graphic of the tiles placed when RMA2 reaches a dead end.
cvar_t * sv_dumpmapassembly
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
int SV_AssembleMap(const char *mapTheme, const char *assembly, char *asmTiles, char *asmPos, char *entityString, const unsigned int seed, bool print)
#define RMA_HIGHEST_SUPPORTED_SEED
int Sys_Milliseconds(void)
char posStr[MAX_TOKEN_CHARS *MAX_TILESTRINGS]
char mapStr[MAX_TOKEN_CHARS *MAX_TILESTRINGS]
static char posStr[MAX_TOKEN_CHARS *MAX_TILESTRINGS]
#define MAX_ALLOWED_TIME_TO_ASSEMBLE
static char mapStr[MAX_TOKEN_CHARS *MAX_TILESTRINGS]
TEST_F(RandomMapAssemblyTest, UMPExtends)