2 * Runnable tests for the edit_distance module using custom element and
5 * @copyright 2016 Kevin Locke <kevin@kevinlocke.name>
6 * MIT license - see LICENSE file for details
9 #include <limits.h> /* UCHAR_MAX */
11 #include <ccan/array_size/array_size.h>
12 #include <ccan/tap/tap.h>
20 #define ed_elem struct color16
21 #define ED_ELEM_EQUAL(e, f) (e.r == f.r && e.g == f.g && e.b == f.b)
22 #define ED_HASH_ELEM(e) ((e.r << 11) | (e.g << 5) | e.b)
23 #define ED_HASH_MAX USHRT_MAX
25 #include <ccan/edit_distance/edit_distance.c>
26 #include <ccan/edit_distance/edit_distance_dl.c>
27 #include <ccan/edit_distance/edit_distance_lcs.c>
28 #include <ccan/edit_distance/edit_distance_lev.c>
29 #include <ccan/edit_distance/edit_distance_rdl.c>
33 const struct color16 src[] = {
39 const struct color16 tgt[] = {
45 ed_size slen = ARRAY_SIZE(src);
46 ed_size tlen = ARRAY_SIZE(tgt);
50 ok1(edit_distance(src, slen, tgt, tlen, EDIT_DISTANCE_LCS) == 6);
51 ok1(edit_distance(src, slen, tgt, tlen, EDIT_DISTANCE_LEV) == 4);
52 ok1(edit_distance(src, slen, tgt, tlen, EDIT_DISTANCE_RDL) == 3);
53 ok1(edit_distance(src, slen, tgt, tlen, EDIT_DISTANCE_DL) == 3);