diff --git a/newbrt/test-gpma-leftmost-dup.c b/newbrt/test-gpma-leftmost-dup.c new file mode 100644 index 00000000000..68063725681 --- /dev/null +++ b/newbrt/test-gpma-leftmost-dup.c @@ -0,0 +1,80 @@ +// Find out if the leftmost value is returned when the besselfun returns 0 for more than one thing. + +#include "gpma.h" +#include "memory.h" +#include "toku_assert.h" +#include "../include/db.h" + +#include +#include + + +int verbose; + +static int compare_strings(u_int32_t alen, void *aval, u_int32_t blen, void *bval, void *extra __attribute__((__unused__))) { + assert(alen==strlen(aval)+1); + assert(blen==strlen(bval)+1); + return strcmp(aval, bval); +} + +static int rcall_ok (u_int32_t nitems __attribute__((__unused__)), u_int32_t *froms __attribute__((__unused__)), u_int32_t *tos __attribute__((__unused__)), struct gitem *items __attribute__((__unused__)), u_int32_t old_N __attribute__((__unused__)), u_int32_t new_N __attribute__((__unused__)), void *extra __attribute__((__unused__))) { + return 0; +} + +static void lookfor (GPMA pma, u_int32_t strlens, int/*char*/ minc, int /*char*/ maxc, int /*char*/ expectc) { + // Make a bessel function that returns 0 for anything in the range [minc, maxc] inclusive. + int zero_for_0_and_1 (u_int32_t dlen, void *dval, void *extra) { + assert(dlen==strlens); + assert(extra==0); + if (((char*)dval)[0]maxc) return +1; + return 0; + } + u_int32_t len, idx; + void *data; + int r = toku_gpma_lookup_bessel(pma, zero_for_0_and_1, 0, 0, &len, &data, &idx); + assert(r==0); + assert(len==strlens); + //printf("Got %c, expect %c\n", ((char*)data)[0], expectc); + assert(((char*)data)[0]==expectc); + } + +static void test_leftmost (void) { + GPMA pma; + int r = toku_gpma_create(&pma, 0); + assert(r==0); + enum { N = 9, strlens=2 }; + char *strings[N]; + int i; + for (i=0; i