void ut_unsorted(int size) { printf("Testing UNSORTED.\n\n"); char *name = "test_unsorted"; make_new_column_file(name, SORTED); column_t *c = malloc(sizeof(column_t)); init_col(c, name); // append things! for(int i = 0; i < size; i ++) { append_value_to_file(c, i); append_value_to_file(c, i-1); } print_data_file(c->fp); init_col(c, name); bv_t *bv = create_bv(2 * size); for(int i = 0; i < size - 3; i ++) { mark_matching_bv_for_unsorted(c, bv, i-1, i); assert(is_marked(bv, (2*i))); assert(is_marked(bv, (2*i + 1))); assert(is_marked(bv, (2*i + 3))); unmark_all_bv(bv); } return; }
static char * test_diskstore_with_deep_folders() { unlink("/tmp/test"); append_value_to_file("/tmp/test/foo/bar/me/now", "123456 10"); mu_assert("Diskstore appending creates the needed directory tree if it isn't already present.", fopen("/tmp/test/foo/bar/me/now", "r") != NULL); system("rm -rf /tmp/test"); return 0; }
static char * test_appending() { unlink("/tmp/test"); append_value_to_file("/tmp/test", "123456 10"); FILE *file = fopen("/tmp/test", "r"); char line[256]; fgets(line, sizeof line, file); mu_assert("Appending writes the correct value to the file specified with an added newline.", strcmp(line, "123456 10\n") == 0); return 0; }