X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fedit_distance%2Ftest%2Frun-types-short.c;fp=ccan%2Fedit_distance%2Ftest%2Frun-types-short.c;h=80922038662342851dd980a5654b61458ef0b525;hb=e0663bef2ec73ed33b22e5a029284296495aab87;hp=0000000000000000000000000000000000000000;hpb=214086cfafb1f5bf7785a29f4497f3adf196ed8b;p=ccan diff --git a/ccan/edit_distance/test/run-types-short.c b/ccan/edit_distance/test/run-types-short.c new file mode 100644 index 00000000..80922038 --- /dev/null +++ b/ccan/edit_distance/test/run-types-short.c @@ -0,0 +1,40 @@ +/** @file + * Runnable tests for the edit_distance module using custom element and + * distance types. + * + * @copyright 2016 Kevin Locke + * MIT license - see LICENSE file for details + */ + +#include /* USHRT_MAX */ + +#include +#include + +#define ed_elem unsigned short +#define ed_dist short +#define ED_HASH_ELEM(e) e +#define ED_HASH_MAX USHRT_MAX + +#include +#include +#include +#include +#include + +int main(void) +{ + const unsigned short src[] = { 0, 1, 2, 3 }; + const unsigned short tgt[] = { 4, 2, 1, 5 }; + ed_size slen = ARRAY_SIZE(src); + ed_size tlen = ARRAY_SIZE(tgt); + + plan_tests(4); + + ok1(edit_distance(src, slen, tgt, tlen, EDIT_DISTANCE_LCS) == 6); + ok1(edit_distance(src, slen, tgt, tlen, EDIT_DISTANCE_LEV) == 4); + ok1(edit_distance(src, slen, tgt, tlen, EDIT_DISTANCE_RDL) == 3); + ok1(edit_distance(src, slen, tgt, tlen, EDIT_DISTANCE_DL) == 3); + + return exit_status(); +}