END_TEST START_TEST(test_str_split_path) { str_t *str = str_from_cstr("test/path"); str_t *half1, *half2; half1 = str_split_path(str, &half2); CHECK_STR(half1, >= 4, == 4, "test"); CHECK_STR(half2, >= 4, == 4, "path"); str_free(str); str_free(half1); str_free(half2); str = str_from_cstr("test/my/path"); half1 = str_split_path(str, &half2); CHECK_STR(half1, >= 7, == 7, "test/my"); CHECK_STR(half2, >= 4, == 4, "path"); str_free(str); str_free(half1); str_free(half2); str = str_from_cstr("testpath"); half1 = str_split_path(str, &half2); fail_unless(half1 == 0, "zero value expected"); CHECK_STR(half2, >= 8, == 8, "testpath"); str_free(str); str_free(half2); }
static void change_dir(const char *filename) { str_t *dir, *fn; fn = str_from_cstr(filename); dir = str_split_path(fn, 0); chdir(dir->data); str_free(dir); str_free(fn); }