forked from github/server
add a unit test for add/free prefixes. fix bad free_prefixes call site.
This commit is contained in:
parent
9f6b374056
commit
f0e255924f
|
@ -1768,7 +1768,6 @@ void free_gamedata(void)
|
||||||
free_units();
|
free_units();
|
||||||
free_regions();
|
free_regions();
|
||||||
free_borders();
|
free_borders();
|
||||||
free_prefixes();
|
|
||||||
|
|
||||||
for (i = 0; i != MAXLOCALES; ++i) {
|
for (i = 0; i != MAXLOCALES; ++i) {
|
||||||
if (defaults[i]) {
|
if (defaults[i]) {
|
||||||
|
|
|
@ -1469,7 +1469,7 @@ static void init_prefixnames(void)
|
||||||
in->next = pnames;
|
in->next = pnames;
|
||||||
in->lang = lang;
|
in->lang = lang;
|
||||||
|
|
||||||
if (!exist) {
|
if (!exist && race_prefixes) {
|
||||||
int key;
|
int key;
|
||||||
for (key = 0; race_prefixes[key]; ++key) {
|
for (key = 0; race_prefixes[key]; ++key) {
|
||||||
variant var;
|
variant var;
|
||||||
|
|
|
@ -1,9 +1,29 @@
|
||||||
#include "prefix.h"
|
#include "prefix.h"
|
||||||
|
|
||||||
|
#include <tests.h>
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
#include <CuTest.h>
|
#include <CuTest.h>
|
||||||
|
|
||||||
|
static void test_add_prefix(CuTest *tc) {
|
||||||
|
test_cleanup();
|
||||||
|
CuAssertPtrEquals(tc, 0, race_prefixes);
|
||||||
|
add_raceprefix("sea");
|
||||||
|
CuAssertPtrNotNull(tc, race_prefixes);
|
||||||
|
CuAssertStrEquals(tc, "sea", race_prefixes[0]);
|
||||||
|
CuAssertPtrEquals(tc, 0, race_prefixes[1]);
|
||||||
|
add_raceprefix("moon");
|
||||||
|
CuAssertStrEquals(tc, "sea", race_prefixes[0]);
|
||||||
|
CuAssertStrEquals(tc, "moon", race_prefixes[1]);
|
||||||
|
CuAssertPtrEquals(tc, 0, race_prefixes[2]);
|
||||||
|
free_prefixes();
|
||||||
|
CuAssertPtrEquals(tc, 0, race_prefixes);
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
CuSuite *get_prefix_suite(void)
|
CuSuite *get_prefix_suite(void)
|
||||||
{
|
{
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
|
SUITE_ADD_TEST(suite, test_add_prefix);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
#include "tests.h"
|
#include "tests.h"
|
||||||
#include "keyword.h"
|
#include "keyword.h"
|
||||||
#include "seen.h"
|
#include "seen.h"
|
||||||
|
#include "prefix.h"
|
||||||
|
|
||||||
#include <kernel/config.h>
|
#include <kernel/config.h>
|
||||||
#include <kernel/region.h>
|
#include <kernel/region.h>
|
||||||
|
@ -84,6 +85,7 @@ void test_cleanup(void)
|
||||||
free_spellbooks();
|
free_spellbooks();
|
||||||
free_gamedata();
|
free_gamedata();
|
||||||
free_seen();
|
free_seen();
|
||||||
|
free_prefixes();
|
||||||
mt_clear();
|
mt_clear();
|
||||||
if (!mt_find("missing_message")) {
|
if (!mt_find("missing_message")) {
|
||||||
mt_register(mt_new_va("missing_message", "name:string", 0));
|
mt_register(mt_new_va("missing_message", "name:string", 0));
|
||||||
|
|
Loading…
Reference in New Issue