forked from github/server
added a test for a purely hypopthetical problem (issue 2032) in keyword parsing.
This commit is contained in:
parent
b761cb5b97
commit
7f0fdd1eb5
|
@ -1,9 +1,11 @@
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
#include "kernel/types.h"
|
#include "kernel/types.h"
|
||||||
|
#include "kernel/config.h"
|
||||||
#include "keyword.h"
|
#include "keyword.h"
|
||||||
#include "util/language.h"
|
#include "util/language.h"
|
||||||
#include "tests.h"
|
#include "tests.h"
|
||||||
|
|
||||||
|
#include <critbit.h>
|
||||||
#include <CuTest.h>
|
#include <CuTest.h>
|
||||||
|
|
||||||
static void test_init_keywords(CuTest *tc) {
|
static void test_init_keywords(CuTest *tc) {
|
||||||
|
@ -51,6 +53,24 @@ static void test_get_keyword_default(CuTest *tc) {
|
||||||
CuAssertIntEquals(tc, K_STUDY, get_keyword("study", lang));
|
CuAssertIntEquals(tc, K_STUDY, get_keyword("study", lang));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_get_shortest_match(CuTest *tc) {
|
||||||
|
struct locale *lang;
|
||||||
|
critbit_tree ** cb;
|
||||||
|
|
||||||
|
test_cleanup();
|
||||||
|
lang = get_or_create_locale("en");
|
||||||
|
|
||||||
|
cb = (critbit_tree **)get_translations(lang, UT_KEYWORDS);
|
||||||
|
/* note that the english order is FIGHT, not COMBAT, so this is a poor example */
|
||||||
|
add_translation(cb, "COMBAT", K_STATUS);
|
||||||
|
add_translation(cb, "COMBATSPELL", K_COMBATSPELL);
|
||||||
|
|
||||||
|
CuAssertIntEquals(tc, NOKEYWORD, get_keyword("", lang));
|
||||||
|
CuAssertIntEquals(tc, K_STATUS, get_keyword("COM", lang));
|
||||||
|
CuAssertIntEquals(tc, K_STATUS, get_keyword("COMBAT", lang));
|
||||||
|
CuAssertIntEquals(tc, K_COMBATSPELL, get_keyword("COMBATS", lang));
|
||||||
|
}
|
||||||
|
|
||||||
#define SUITE_DISABLE_TEST(suite, test) (void)test
|
#define SUITE_DISABLE_TEST(suite, test) (void)test
|
||||||
|
|
||||||
CuSuite *get_keyword_suite(void)
|
CuSuite *get_keyword_suite(void)
|
||||||
|
@ -59,6 +79,7 @@ CuSuite *get_keyword_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_init_keyword);
|
SUITE_ADD_TEST(suite, test_init_keyword);
|
||||||
SUITE_ADD_TEST(suite, test_init_keywords);
|
SUITE_ADD_TEST(suite, test_init_keywords);
|
||||||
SUITE_ADD_TEST(suite, test_findkeyword);
|
SUITE_ADD_TEST(suite, test_findkeyword);
|
||||||
|
SUITE_ADD_TEST(suite, test_get_shortest_match);
|
||||||
SUITE_DISABLE_TEST(suite, test_get_keyword_default);
|
SUITE_DISABLE_TEST(suite, test_get_keyword_default);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue