forked from github/server
add missing tests for groups.
This commit is contained in:
parent
1d7c193de6
commit
483a2ba3de
|
@ -3,6 +3,7 @@ project(kernel C)
|
||||||
SET(_TEST_FILES
|
SET(_TEST_FILES
|
||||||
build.test.c
|
build.test.c
|
||||||
config.test.c
|
config.test.c
|
||||||
|
group.test.c
|
||||||
faction.test.c
|
faction.test.c
|
||||||
unit.test.c
|
unit.test.c
|
||||||
save.test.c
|
save.test.c
|
||||||
|
|
|
@ -22,9 +22,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* bitfield value for group::flags */
|
|
||||||
#define GFL_ALIVE 0x01 /* There is at least one struct unit in the group */
|
|
||||||
|
|
||||||
struct gamedata;
|
struct gamedata;
|
||||||
|
|
||||||
typedef struct group {
|
typedef struct group {
|
||||||
|
@ -34,7 +31,6 @@ extern "C" {
|
||||||
struct attrib *attribs;
|
struct attrib *attribs;
|
||||||
char *name;
|
char *name;
|
||||||
struct ally *allies;
|
struct ally *allies;
|
||||||
int flags;
|
|
||||||
int gid;
|
int gid;
|
||||||
int members;
|
int members;
|
||||||
} group;
|
} group;
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
#include <platform.h>
|
||||||
|
#include "types.h"
|
||||||
|
#include "group.h"
|
||||||
|
#include "faction.h"
|
||||||
|
#include "unit.h"
|
||||||
|
#include "region.h"
|
||||||
|
|
||||||
|
#include <CuTest.h>
|
||||||
|
#include <tests.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
static void test_group(CuTest * tc)
|
||||||
|
{
|
||||||
|
unit *u;
|
||||||
|
region *r;
|
||||||
|
faction *f;
|
||||||
|
group *g;
|
||||||
|
|
||||||
|
test_cleanup();
|
||||||
|
test_create_world();
|
||||||
|
r = findregion(0, 0);
|
||||||
|
f = test_create_faction(0);
|
||||||
|
assert(r && f);
|
||||||
|
u = test_create_unit(f, r);
|
||||||
|
assert(u);
|
||||||
|
CuAssertTrue(tc, join_group(u, "hodor"));
|
||||||
|
CuAssertPtrNotNull(tc, (g = get_group(u)));
|
||||||
|
CuAssertStrEquals(tc, "hodor", g->name);
|
||||||
|
CuAssertIntEquals(tc, 1, g->members);
|
||||||
|
set_group(u, 0);
|
||||||
|
CuAssertIntEquals(tc, 0, g->members);
|
||||||
|
CuAssertPtrEquals(tc, 0, get_group(u));
|
||||||
|
set_group(u, g);
|
||||||
|
CuAssertIntEquals(tc, 1, g->members);
|
||||||
|
CuAssertPtrEquals(tc, g, get_group(u));
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
CuSuite *get_group_suite(void)
|
||||||
|
{
|
||||||
|
CuSuite *suite = CuSuiteNew();
|
||||||
|
SUITE_ADD_TEST(suite, test_group);
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ int RunAllTests(void)
|
||||||
/* kernel */
|
/* kernel */
|
||||||
ADD_TESTS(suite, unit);
|
ADD_TESTS(suite, unit);
|
||||||
ADD_TESTS(suite, faction);
|
ADD_TESTS(suite, faction);
|
||||||
|
ADD_TESTS(suite, group);
|
||||||
ADD_TESTS(suite, build);
|
ADD_TESTS(suite, build);
|
||||||
ADD_TESTS(suite, pool);
|
ADD_TESTS(suite, pool);
|
||||||
ADD_TESTS(suite, curse);
|
ADD_TESTS(suite, curse);
|
||||||
|
|
Loading…
Reference in New Issue