forked from github/server
clumsy repair of duplicate regions for range >= 2 (RF_MARK)
This commit is contained in:
parent
c755c1d69e
commit
9eb376e0e5
2 changed files with 27 additions and 1 deletions
|
@ -1118,6 +1118,7 @@ int get_regions_distance_arr(region *rc, int radius, region *result[], int size)
|
||||||
|
|
||||||
if (size>n) {
|
if (size>n) {
|
||||||
result[n++] = rc;
|
result[n++] = rc;
|
||||||
|
fset(rc, RF_MARK);
|
||||||
}
|
}
|
||||||
for (i = 0; i != n; ++i) {
|
for (i = 0; i != n; ++i) {
|
||||||
region *r;
|
region *r;
|
||||||
|
@ -1134,8 +1135,9 @@ int get_regions_distance_arr(region *rc, int radius, region *result[], int size)
|
||||||
r = adj[d];
|
r = adj[d];
|
||||||
if (r) {
|
if (r) {
|
||||||
if (size > n) {
|
if (size > n) {
|
||||||
if (dist < distance(rc, r)) {
|
if (!fval(r, RF_MARK) && dist < distance(rc, r)) {
|
||||||
result[n++] = r;
|
result[n++] = r;
|
||||||
|
fset(r, RF_MARK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1145,6 +1147,9 @@ int get_regions_distance_arr(region *rc, int radius, region *result[], int size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (i = 0; i != n; ++i) {
|
||||||
|
freset(result[i], RF_MARK);
|
||||||
|
}
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -425,6 +425,26 @@ static void test_seen_travelthru(CuTest *tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_region_distance_max(CuTest *tc) {
|
||||||
|
region *r;
|
||||||
|
region *result[64];
|
||||||
|
int x, y;
|
||||||
|
test_setup();
|
||||||
|
r = test_create_region(0, 0, 0);
|
||||||
|
for (x=-3;x<=3;++x) {
|
||||||
|
for (y = -3; y <= 3; ++y) {
|
||||||
|
if (x != 0 || y != 0) {
|
||||||
|
test_create_region(x, y, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CuAssertIntEquals(tc, 1, get_regions_distance_arr(r, 0, result, 64));
|
||||||
|
CuAssertIntEquals(tc, 7, get_regions_distance_arr(r, 1, result, 64));
|
||||||
|
CuAssertIntEquals(tc, 19, get_regions_distance_arr(r, 2, result, 64));
|
||||||
|
CuAssertIntEquals(tc, 37, get_regions_distance_arr(r, 3, result, 64));
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
static void test_region_distance(CuTest *tc) {
|
static void test_region_distance(CuTest *tc) {
|
||||||
region *r;
|
region *r;
|
||||||
region *result[8];
|
region *result[8];
|
||||||
|
@ -465,6 +485,7 @@ CuSuite *get_reports_suite(void)
|
||||||
{
|
{
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
SUITE_ADD_TEST(suite, test_region_distance);
|
SUITE_ADD_TEST(suite, test_region_distance);
|
||||||
|
SUITE_ADD_TEST(suite, test_region_distance_max);
|
||||||
SUITE_ADD_TEST(suite, test_region_distance_ql);
|
SUITE_ADD_TEST(suite, test_region_distance_ql);
|
||||||
SUITE_ADD_TEST(suite, test_prepare_report);
|
SUITE_ADD_TEST(suite, test_prepare_report);
|
||||||
SUITE_ADD_TEST(suite, test_seen_neighbours);
|
SUITE_ADD_TEST(suite, test_seen_neighbours);
|
||||||
|
|
Loading…
Reference in a new issue