forked from github/server
test inside_building vs. overflow
fix default building capacity (should be 1 per size)
This commit is contained in:
parent
42ae086def
commit
4bf2509fb3
3 changed files with 24 additions and 2 deletions
|
@ -115,7 +115,7 @@ building_type *bt_get_or_create(const char *name)
|
||||||
btype->_name = _strdup(name);
|
btype->_name = _strdup(name);
|
||||||
btype->auraregen = 1.0;
|
btype->auraregen = 1.0;
|
||||||
btype->maxsize = -1;
|
btype->maxsize = -1;
|
||||||
btype->capacity = -1;
|
btype->capacity = 1;
|
||||||
btype->maxcapacity = -1;
|
btype->maxcapacity = -1;
|
||||||
bt_register(btype);
|
bt_register(btype);
|
||||||
}
|
}
|
||||||
|
|
|
@ -373,7 +373,7 @@ static void test_btype_defaults(CuTest *tc) {
|
||||||
CuAssertTrue(tc, !btype->taxes);
|
CuAssertTrue(tc, !btype->taxes);
|
||||||
CuAssertDblEquals(tc, 1.0, btype->auraregen, 0.0);
|
CuAssertDblEquals(tc, 1.0, btype->auraregen, 0.0);
|
||||||
CuAssertIntEquals(tc, -1, btype->maxsize);
|
CuAssertIntEquals(tc, -1, btype->maxsize);
|
||||||
CuAssertIntEquals(tc, -1, btype->capacity);
|
CuAssertIntEquals(tc, 1, btype->capacity);
|
||||||
CuAssertIntEquals(tc, -1, btype->maxcapacity);
|
CuAssertIntEquals(tc, -1, btype->maxcapacity);
|
||||||
CuAssertIntEquals(tc, 0, btype->magres);
|
CuAssertIntEquals(tc, 0, btype->magres);
|
||||||
CuAssertIntEquals(tc, 0, btype->magresbonus);
|
CuAssertIntEquals(tc, 0, btype->magresbonus);
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <kernel/config.h>
|
#include <kernel/config.h>
|
||||||
#include <kernel/curse.h>
|
#include <kernel/curse.h>
|
||||||
#include <kernel/item.h>
|
#include <kernel/item.h>
|
||||||
|
#include <kernel/building.h>
|
||||||
#include <kernel/faction.h>
|
#include <kernel/faction.h>
|
||||||
#include <kernel/order.h>
|
#include <kernel/order.h>
|
||||||
#include <kernel/race.h>
|
#include <kernel/race.h>
|
||||||
|
@ -376,6 +377,26 @@ static void test_produceexp(CuTest *tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_inside_building(CuTest *tc) {
|
||||||
|
unit *u;
|
||||||
|
building *b;
|
||||||
|
|
||||||
|
test_cleanup();
|
||||||
|
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||||
|
b = test_create_building(u->region, 0);
|
||||||
|
|
||||||
|
b->size = 1;
|
||||||
|
scale_number(u, 1);
|
||||||
|
CuAssertPtrEquals(tc, 0, inside_building(u));
|
||||||
|
u->building = b;
|
||||||
|
CuAssertPtrEquals(tc, b, inside_building(u));
|
||||||
|
scale_number(u, 2);
|
||||||
|
CuAssertPtrEquals(tc, 0, inside_building(u));
|
||||||
|
b->size = 2;
|
||||||
|
CuAssertPtrEquals(tc, b, inside_building(u));
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
CuSuite *get_unit_suite(void)
|
CuSuite *get_unit_suite(void)
|
||||||
{
|
{
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
|
@ -394,6 +415,7 @@ CuSuite *get_unit_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_skill_hunger);
|
SUITE_ADD_TEST(suite, test_skill_hunger);
|
||||||
SUITE_ADD_TEST(suite, test_skill_familiar);
|
SUITE_ADD_TEST(suite, test_skill_familiar);
|
||||||
SUITE_ADD_TEST(suite, test_age_familiar);
|
SUITE_ADD_TEST(suite, test_age_familiar);
|
||||||
|
SUITE_ADD_TEST(suite, test_inside_building);
|
||||||
SUITE_ADD_TEST(suite, test_produceexp);
|
SUITE_ADD_TEST(suite, test_produceexp);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue