quakeforge/tools/qfcc/test/test-defspace.c
Bill Currie 6d5ffa9f8e [build] Move to non-recursive make
There's still some cleanup to do, but everything seems to be working
nicely: `make -j` works, `make distcheck` passes. There is probably
plenty of bitrot in the package directories (RPM, debian), though.

The vc project files have been removed since those versions are way out
of date and quakeforge is pretty much dependent on gcc now anyway.

Most of the old Makefile.am files  are now Makemodule.am.  This should
allow for new Makefile.am files that allow local building (to be added
on an as-needed bases).  The current remaining Makefile.am files are for
standalone sub-projects.a

The installable bins are currently built in the top-level build
directory. This may change if the clutter gets to be too much.

While this does make a noticeable difference in build times, the main
reason for the switch was to take care of the growing dependency issues:
now it's possible to build tools for code generation (eg, using qfcc and
ruamoko programs for code-gen).
2020-06-25 11:35:37 +09:00

117 lines
2.1 KiB
C

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include "tools/qfcc/include/class.h"
#include "tools/qfcc/include/expr.h"
#include "tools/qfcc/include/function.h"
#include "tools/qfcc/include/options.h"
#include "tools/qfcc/include/strpool.h"
#include "tools/qfcc/include/qfcc.h"
#include "tools/qfcc/test/test-defspace.h"
options_t options;
pr_info_t pr;
function_t *current_func;
class_type_t *current_class;
void
free_def (def_t *def)
{
if (0) free (def);
}
__attribute__((const))const char *
get_class_name (class_type_t *class_type, int prett)
{
return 0;
}
expr_t *
new_expr (void)
{
return calloc(1, sizeof (expr_t));
}
static int
check_init_state (const defspace_t *space, const char *name)
{
int pass = 1;
if (space->free_locs) {
printf ("%s free_locs not null\n", name);
pass = 0;
}
if (space->defs) {
printf ("%s defs not null\n", name);
pass = 0;
}
if (space->def_tail != &space->defs) {
printf ("%s def_tail not pointing to defs\n", name);
pass = 0;
}
if (space->data) {
printf ("%s data not null\n", name);
pass = 0;
}
if (space->size) {
printf ("%s size not 0\n", name);
pass = 0;
}
if (space->max_size) {
printf ("%s max_size not 0\n", name);
pass = 0;
}
if (!space->grow) {
printf ("%s grow is null\n", name);
pass = 0;
}
if (space->qfo_space) {
printf ("%s qfo_space not 0\n", name);
pass = 0;
}
return pass;
}
static int
test_init (void)
{
int pass = 1;
defspace_t *backed = defspace_new (ds_backed);
defspace_t *virtual = defspace_new (ds_virtual);
if (backed->grow == virtual->grow) {
printf ("expected different grow functions for backed and virtual\n");
pass = 0;
}
if (backed->type != ds_backed) {
printf ("backed ds has wrong type\n");
pass = 0;
}
if (virtual->type != ds_virtual) {
printf ("virtual ds has wrong type\n");
pass = 0;
}
pass &= check_init_state (backed, "backed");
pass &= check_init_state (virtual, "virtual");
return pass;
}
int
main (int argc, const char **argv)
{
pr.strings = strpool_new ();
int pass = 1;
pass &= test_init ();
return !pass;
}