Canonicalise (a local copy of) the key structures given to termkey_keycmp() before comparing them

This commit is contained in:
Paul LeoNerd Evans
2011-09-06 22:49:05 +01:00
parent 3008ed29d1
commit 8f32ac525f
3 changed files with 34 additions and 15 deletions

View File

@@ -6,7 +6,7 @@ int main(int argc, char *argv[])
TermKey *tk;
TermKeyKey key1, key2;
plan_tests(10);
plan_tests(12);
tk = termkey_new(0, TERMKEY_FLAG_NOTERMIOS);
@@ -44,6 +44,18 @@ int main(int argc, char *argv[])
ok(termkey_keycmp(tk, &key1, &key2) < 0, "cmpkey orders KEYSYM after UNICODE");
ok(termkey_keycmp(tk, &key2, &key1) > 0, "cmpkey orders UNICODE before KEYSYM");
key1.type = TERMKEY_TYPE_KEYSYM;
key1.code.sym = TERMKEY_SYM_SPACE;
key1.modifiers = 0;
key2.type = TERMKEY_TYPE_UNICODE;
key2.code.codepoint = ' ';
key2.modifiers = 0;
is_int(termkey_keycmp(tk, &key1, &key2), 0, "cmpkey considers KEYSYM/SPACE and UNICODE/SP identical");
termkey_set_canonflags(tk, termkey_get_canonflags(tk) | TERMKEY_CANON_SPACESYMBOL);
is_int(termkey_keycmp(tk, &key1, &key2), 0, "cmpkey considers KEYSYM/SPACE and UNICODE/SP identical under SPACESYMBOL");
termkey_destroy(tk);
return exit_status();