mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-27 22:21:00 +00:00
More defspace tests.
This commit is contained in:
parent
6f28ab2a68
commit
d95c01be1a
4 changed files with 63 additions and 2 deletions
|
@ -211,5 +211,5 @@ voidfor.run: Makefile build-run
|
||||||
include ./$(DEPDIR)/voidfor.Qo
|
include ./$(DEPDIR)/voidfor.Qo
|
||||||
|
|
||||||
|
|
||||||
EXTRA_DIST= test-bi.h build-run
|
EXTRA_DIST= test-bi.h build-run test-defspace.h
|
||||||
CLEANFILES= *.dat *.sym *.qfo *.run *.frame
|
CLEANFILES= *.dat *.sym *.qfo *.run *.frame
|
||||||
|
|
|
@ -5,13 +5,14 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "class.h"
|
#include "class.h"
|
||||||
#include "defspace.h"
|
|
||||||
#include "expr.h"
|
#include "expr.h"
|
||||||
#include "function.h"
|
#include "function.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "strpool.h"
|
#include "strpool.h"
|
||||||
#include "qfcc.h"
|
#include "qfcc.h"
|
||||||
|
|
||||||
|
#include "test-defspace.h"
|
||||||
|
|
||||||
options_t options;
|
options_t options;
|
||||||
pr_info_t pr;
|
pr_info_t pr;
|
||||||
function_t *current_func;
|
function_t *current_func;
|
||||||
|
|
6
tools/qfcc/test/test-defspace.h
Normal file
6
tools/qfcc/test/test-defspace.h
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#include "def.h"
|
||||||
|
#include "defspace.h"
|
||||||
|
|
||||||
|
int def_list_is_empty (const defspace_t *space);
|
||||||
|
int def_list_is_valid (const defspace_t *space);
|
||||||
|
int free_locs_is_valid (const defspace_t *space);
|
|
@ -1 +1,55 @@
|
||||||
#include "../source/defspace.c"
|
#include "../source/defspace.c"
|
||||||
|
#include "test-defspace.h"
|
||||||
|
|
||||||
|
__attribute__((pure)) int
|
||||||
|
def_list_is_empty (const defspace_t *space)
|
||||||
|
{
|
||||||
|
return (!space->defs && space->def_tail == &space->defs);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__((pure)) int
|
||||||
|
def_list_is_valid (const defspace_t *space)
|
||||||
|
{
|
||||||
|
def_t *const *d = &space->defs;
|
||||||
|
|
||||||
|
while (*d) {
|
||||||
|
d = &(*d)->next;
|
||||||
|
}
|
||||||
|
return d == space->def_tail;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
free_locs_is_valid (const defspace_t *space)
|
||||||
|
{
|
||||||
|
int free_space = 0;
|
||||||
|
const locref_t *loc;
|
||||||
|
|
||||||
|
for (loc = space->free_locs; loc; loc = loc->next) {
|
||||||
|
if (loc->ofs < 0) {
|
||||||
|
printf ("negative offset in free_locs\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (loc->size <= 0) {
|
||||||
|
printf ("zero or negative size in free_locs\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (loc->next && loc->ofs > loc->next->ofs) {
|
||||||
|
printf ("free_locs not in ascending order\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (loc->next && loc->ofs + loc->size > loc->next->ofs) {
|
||||||
|
printf ("overlap in free_locs\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (loc->next && loc->ofs + loc->size == loc->next->ofs) {
|
||||||
|
printf ("adjoining nodes in free_locs\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
free_space += loc->size;
|
||||||
|
}
|
||||||
|
if (free_space > space->size) {
|
||||||
|
printf ("free_locs describes too much free space\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue