diff --git a/src/mwindow.c b/src/mwindow.c index fa5549021..b59c4d2f7 100644 --- a/src/mwindow.c +++ b/src/mwindow.c @@ -218,9 +218,8 @@ unsigned char *git_mwindow_open( for (w = mwf->windows; w; w = w->next) { if (git_mwindow_contains(w, offset) && - git_mwindow_contains(w, offset + extra)) + git_mwindow_contains(w, offset + extra)) break; - } } /* diff --git a/tests-clar/buf/basic.c b/tests-clar/buf/basic.c index 5d4a5fff9..d558757a9 100644 --- a/tests-clar/buf/basic.c +++ b/tests-clar/buf/basic.c @@ -8,7 +8,7 @@ void test_buf_basic__resize(void) git_buf buf1 = GIT_BUF_INIT; git_buf_puts(&buf1, test_string); cl_assert(git_buf_oom(&buf1) == 0); - cl_assert_strequal(git_buf_cstr(&buf1), test_string); + cl_assert_equal_s(git_buf_cstr(&buf1), test_string); git_buf_puts(&buf1, test_string); cl_assert(strlen(git_buf_cstr(&buf1)) == strlen(test_string) * 2); @@ -20,10 +20,10 @@ void test_buf_basic__printf(void) git_buf buf2 = GIT_BUF_INIT; git_buf_printf(&buf2, "%s %s %d ", "shoop", "da", 23); cl_assert(git_buf_oom(&buf2) == 0); - cl_assert_strequal(git_buf_cstr(&buf2), "shoop da 23 "); + cl_assert_equal_s(git_buf_cstr(&buf2), "shoop da 23 "); git_buf_printf(&buf2, "%s %d", "woop", 42); cl_assert(git_buf_oom(&buf2) == 0); - cl_assert_strequal(git_buf_cstr(&buf2), "shoop da 23 woop 42"); + cl_assert_equal_s(git_buf_cstr(&buf2), "shoop da 23 woop 42"); git_buf_free(&buf2); } diff --git a/tests-clar/config/new.c b/tests-clar/config/new.c index 651e73931..78e8ec828 100644 --- a/tests-clar/config/new.c +++ b/tests-clar/config/new.c @@ -26,9 +26,9 @@ void test_config_new__write_new_config(void) cl_git_pass(git_config_add_file(config, file, 0)); cl_git_pass(git_config_get_string(config, "color.ui", &out)); - cl_assert_strequal(out, "auto"); + cl_assert_equal_s(out, "auto"); cl_git_pass(git_config_get_string(config, "core.editor", &out)); - cl_assert_strequal(out, "ed"); + cl_assert_equal_s(out, "ed"); git_config_free(config); diff --git a/tests-clar/config/read.c b/tests-clar/config/read.c index a8ed44d94..3e9a8d4bf 100644 --- a/tests-clar/config/read.c +++ b/tests-clar/config/read.c @@ -28,9 +28,9 @@ void test_config_read__case_sensitive(void) cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config1"))); cl_git_pass(git_config_get_string(cfg, "this.that.other", &str)); - cl_assert_strequal(str, "true"); + cl_assert_equal_s(str, "true"); cl_git_pass(git_config_get_string(cfg, "this.That.other", &str)); - cl_assert_strequal(str, "yes"); + cl_assert_equal_s(str, "yes"); cl_git_pass(git_config_get_bool(cfg, "this.that.other", &i)); cl_assert(i == 1); @@ -55,7 +55,7 @@ void test_config_read__multiline_value(void) cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config2"))); cl_git_pass(git_config_get_string(cfg, "this.That.and", &str)); - cl_assert_strequal(str, "one one one two two three three"); + cl_assert_equal_s(str, "one one one two two three three"); git_config_free(cfg); } @@ -71,7 +71,7 @@ void test_config_read__subsection_header(void) cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config3"))); cl_git_pass(git_config_get_string(cfg, "section.subsection.var", &str)); - cl_assert_strequal(str, "hello"); + cl_assert_equal_s(str, "hello"); /* The subsection is transformed to lower-case */ cl_must_fail(git_config_get_string(cfg, "section.subSectIon.var", &str)); @@ -171,10 +171,10 @@ void test_config_read__prefixes(void) cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config9"))); cl_git_pass(git_config_get_string(cfg, "remote.ab.url", &str)); - cl_assert_strequal(str, "http://example.com/git/ab"); + cl_assert_equal_s(str, "http://example.com/git/ab"); cl_git_pass(git_config_get_string(cfg, "remote.abba.url", &str)); - cl_assert_strequal(str, "http://example.com/git/abba"); + cl_assert_equal_s(str, "http://example.com/git/abba"); git_config_free(cfg); } diff --git a/tests-clar/hash/table.c b/tests-clar/hash/table.c deleted file mode 100644 index e69d38618..000000000 --- a/tests-clar/hash/table.c +++ /dev/null @@ -1,162 +0,0 @@ -#include "clar_libgit2.h" - -#include "hashtable.h" -#include "hash.h" - - -// Helpers -typedef struct _aux_object { - int __bulk; - git_oid id; - int visited; -} table_item; - -static uint32_t hash_func(const void *key, int hash_id) -{ - uint32_t r; - const git_oid *id = (const git_oid *)key; - - memcpy(&r, id->id + (hash_id * sizeof(uint32_t)), sizeof(r)); - return r; -} - -static int hash_cmpkey(const void *a, const void *b) -{ - return git_oid_cmp((const git_oid*)a, (const git_oid*)b); -} - - -void test_hash_table__new(void) -{ - // create a new hashtable - git_hashtable *table = NULL; - - table = git_hashtable_alloc(55, hash_func, hash_cmpkey); - cl_assert(table != NULL); - cl_assert(table->size_mask + 1 == 64); - - git_hashtable_free(table); -} - -void test_hash_table__fill(void) -{ - // fill the hashtable with random entries - const int objects_n = 32; - int i; - table_item *objects; - git_hashtable *table = NULL; - - table = git_hashtable_alloc(objects_n * 2, hash_func, hash_cmpkey); - cl_assert(table != NULL); - - objects = (table_item *)git__malloc(objects_n * sizeof(table_item)); - memset(objects, 0x0, objects_n * sizeof(table_item)); - - /* populate the hash table */ - for (i = 0; i < objects_n; ++i) { - git_hash_buf(&(objects[i].id), &i, sizeof(int)); - cl_git_pass(git_hashtable_insert(table, &(objects[i].id), &(objects[i]))); - } - - /* make sure all the inserted objects can be found */ - for (i = 0; i < objects_n; ++i) { - git_oid id; - table_item *ob; - - git_hash_buf(&id, &i, sizeof(int)); - ob = (table_item *)git_hashtable_lookup(table, &id); - - cl_assert(ob != NULL); - cl_assert(ob == &(objects[i])); - } - - /* make sure we cannot find inexisting objects */ - for (i = 0; i < 50; ++i) { - int hash_id; - git_oid id; - - hash_id = (rand() % 50000) + objects_n; - git_hash_buf(&id, &hash_id, sizeof(int)); - cl_assert(git_hashtable_lookup(table, &id) == NULL); - } - - git_hashtable_free(table); - git__free(objects); -} - - -void test_hash_table__resize(void) -{ - // make sure the table resizes automatically - const int objects_n = 64; - int i; - unsigned int old_size; - table_item *objects; - git_hashtable *table = NULL; - - table = git_hashtable_alloc(objects_n, hash_func, hash_cmpkey); - cl_assert(table != NULL); - - objects = (table_item*)git__malloc(objects_n * sizeof(table_item)); - memset(objects, 0x0, objects_n * sizeof(table_item)); - - old_size = table->size_mask + 1; - - /* populate the hash table -- should be automatically resized */ - for (i = 0; i < objects_n; ++i) { - git_hash_buf(&(objects[i].id), &i, sizeof(int)); - cl_git_pass(git_hashtable_insert(table, &(objects[i].id), &(objects[i]))); - } - - cl_assert(table->size_mask > old_size); - - /* make sure all the inserted objects can be found */ - for (i = 0; i < objects_n; ++i) { - git_oid id; - table_item *ob; - - git_hash_buf(&id, &i, sizeof(int)); - ob = (table_item *)git_hashtable_lookup(table, &id); - - cl_assert(ob != NULL); - cl_assert(ob == &(objects[i])); - } - - git_hashtable_free(table); - git__free(objects); -} - - -void test_hash_table__iterate(void) -{ - // iterate through all the contents of the table - - const int objects_n = 32; - int i; - table_item *objects, *ob; - - git_hashtable *table = NULL; - - table = git_hashtable_alloc(objects_n * 2, hash_func, hash_cmpkey); - cl_assert(table != NULL); - - objects = git__malloc(objects_n * sizeof(table_item)); - memset(objects, 0x0, objects_n * sizeof(table_item)); - - /* populate the hash table */ - for (i = 0; i < objects_n; ++i) { - git_hash_buf(&(objects[i].id), &i, sizeof(int)); - cl_git_pass(git_hashtable_insert(table, &(objects[i].id), &(objects[i]))); - } - - GIT_HASHTABLE_FOREACH_VALUE(table, ob, ob->visited = 1); - - /* make sure all nodes have been visited */ - for (i = 0; i < objects_n; ++i) - { - cl_assert(objects[i].visited); - } - - git_hashtable_free(table); - git__free(objects); -} diff --git a/tests-clar/index/tests.c b/tests-clar/index/tests.c index a8ca2eece..3d01b7cfb 100644 --- a/tests-clar/index/tests.c +++ b/tests-clar/index/tests.c @@ -107,7 +107,7 @@ void test_index_tests__default_test_index(void) for (i = 0; i < ARRAY_SIZE(test_entries); ++i) { git_index_entry *e = entries[test_entries[i].index]; - cl_assert_strequal(e->path, test_entries[i].path); + cl_assert_equal_s(e->path, test_entries[i].path); cl_assert(e->mtime.seconds == test_entries[i].mtime); cl_assert(e->file_size == test_entries[i].file_size); } diff --git a/tests-clar/network/createremotethenload.c b/tests-clar/network/createremotethenload.c index a805e2ddf..45931d376 100644 --- a/tests-clar/network/createremotethenload.c +++ b/tests-clar/network/createremotethenload.c @@ -28,6 +28,6 @@ void test_network_createremotethenload__cleanup(void) void test_network_createremotethenload__parsing(void) { - cl_assert_strequal(git_remote_name(_remote), "origin"); - cl_assert_strequal(git_remote_url(_remote), url); + cl_assert_equal_s(git_remote_name(_remote), "origin"); + cl_assert_equal_s(git_remote_url(_remote), url); } diff --git a/tests-clar/network/remotes.c b/tests-clar/network/remotes.c index 5dc5f3387..9d414c914 100644 --- a/tests-clar/network/remotes.c +++ b/tests-clar/network/remotes.c @@ -27,8 +27,8 @@ void test_network_remotes__cleanup(void) void test_network_remotes__parsing(void) { - cl_assert_strequal(git_remote_name(_remote), "test"); - cl_assert_strequal(git_remote_url(_remote), "git://github.com/libgit2/libgit2"); + cl_assert_equal_s(git_remote_name(_remote), "test"); + cl_assert_equal_s(git_remote_url(_remote), "git://github.com/libgit2/libgit2"); } void test_network_remotes__parsing_ssh_remote(void) @@ -53,24 +53,24 @@ void test_network_remotes__unsupported_transport_methods_are_unsupported(void) void test_network_remotes__refspec_parsing(void) { - cl_assert_strequal(git_refspec_src(_refspec), "refs/heads/*"); - cl_assert_strequal(git_refspec_dst(_refspec), "refs/remotes/test/*"); + cl_assert_equal_s(git_refspec_src(_refspec), "refs/heads/*"); + cl_assert_equal_s(git_refspec_dst(_refspec), "refs/remotes/test/*"); } void test_network_remotes__set_fetchspec(void) { cl_git_pass(git_remote_set_fetchspec(_remote, "refs/*:refs/*")); _refspec = git_remote_fetchspec(_remote); - cl_assert_strequal(git_refspec_src(_refspec), "refs/*"); - cl_assert_strequal(git_refspec_dst(_refspec), "refs/*"); + cl_assert_equal_s(git_refspec_src(_refspec), "refs/*"); + cl_assert_equal_s(git_refspec_dst(_refspec), "refs/*"); } void test_network_remotes__set_pushspec(void) { cl_git_pass(git_remote_set_pushspec(_remote, "refs/*:refs/*")); _refspec = git_remote_pushspec(_remote); - cl_assert_strequal(git_refspec_src(_refspec), "refs/*"); - cl_assert_strequal(git_refspec_dst(_refspec), "refs/*"); + cl_assert_equal_s(git_refspec_src(_refspec), "refs/*"); + cl_assert_equal_s(git_refspec_dst(_refspec), "refs/*"); } void test_network_remotes__save(void) @@ -90,13 +90,13 @@ void test_network_remotes__save(void) _refspec = git_remote_fetchspec(_remote); cl_assert(_refspec != NULL); - cl_assert_strequal(git_refspec_src(_refspec), "refs/heads/*"); - cl_assert_strequal(git_refspec_dst(_refspec), "refs/remotes/upstream/*"); + cl_assert_equal_s(git_refspec_src(_refspec), "refs/heads/*"); + cl_assert_equal_s(git_refspec_dst(_refspec), "refs/remotes/upstream/*"); _refspec = git_remote_pushspec(_remote); cl_assert(_refspec != NULL); - cl_assert_strequal(git_refspec_src(_refspec), "refs/heads/*"); - cl_assert_strequal(git_refspec_dst(_refspec), "refs/heads/*"); + cl_assert_equal_s(git_refspec_src(_refspec), "refs/heads/*"); + cl_assert_equal_s(git_refspec_dst(_refspec), "refs/heads/*"); } void test_network_remotes__fnmatch(void) @@ -111,7 +111,7 @@ void test_network_remotes__transform(void) memset(ref, 0x0, sizeof(ref)); cl_git_pass(git_refspec_transform(ref, sizeof(ref), _refspec, "refs/heads/master")); - cl_assert_strequal(ref, "refs/remotes/test/master"); + cl_assert_equal_s(ref, "refs/remotes/test/master"); } void test_network_remotes__transform_r(void) @@ -119,7 +119,7 @@ void test_network_remotes__transform_r(void) git_buf buf = GIT_BUF_INIT; cl_git_pass(git_refspec_transform_r(&buf, _refspec, "refs/heads/master")); - cl_assert_strequal(git_buf_cstr(&buf), "refs/remotes/test/master"); + cl_assert_equal_s(git_buf_cstr(&buf), "refs/remotes/test/master"); git_buf_free(&buf); } diff --git a/tests-clar/notes/notes.c b/tests-clar/notes/notes.c index bb5a85dd1..ca82ab29c 100644 --- a/tests-clar/notes/notes.c +++ b/tests-clar/notes/notes.c @@ -33,11 +33,11 @@ void test_notes_notes__1(void) cl_git_pass(git_note_read(&_note, _repo, NULL, &oid)); - cl_assert_strequal(git_note_message(_note), "hello world\n"); + cl_assert_equal_s(git_note_message(_note), "hello world\n"); cl_assert(!git_oid_cmp(git_note_oid(_note), ¬e_oid)); cl_git_pass(git_blob_lookup(&_blob, _repo, ¬e_oid)); - cl_assert_strequal(git_note_message(_note), git_blob_rawcontent(_blob)); + cl_assert_equal_s(git_note_message(_note), git_blob_rawcontent(_blob)); cl_git_fail(git_note_create(¬e_oid, _repo, _sig, _sig, NULL, &oid, "hello world\n")); cl_git_fail(git_note_create(¬e_oid, _repo, _sig, _sig, "refs/notes/some/namespace", &oid, "hello world\n")); diff --git a/tests-clar/object/raw/compare.c b/tests-clar/object/raw/compare.c index 6dc6d713f..1c9ce4b81 100644 --- a/tests-clar/object/raw/compare.c +++ b/tests-clar/object/raw/compare.c @@ -87,7 +87,7 @@ void test_object_raw_compare__compare_fmt_oids(void) /* Format produced the right result */ out[GIT_OID_HEXSZ] = '\0'; - cl_assert_strequal(exp, out); + cl_assert_equal_s(exp, out); } void test_object_raw_compare__compare_allocfmt_oids(void) @@ -100,7 +100,7 @@ void test_object_raw_compare__compare_allocfmt_oids(void) out = git_oid_allocfmt(&in); cl_assert(out); - cl_assert_strequal(exp, out); + cl_assert_equal_s(exp, out); git__free(out); } @@ -120,5 +120,5 @@ void test_object_raw_compare__compare_pathfmt_oids(void) /* Format produced the right result */ out[GIT_OID_HEXSZ + 1] = '\0'; - cl_assert_strequal(exp2, out); + cl_assert_equal_s(exp2, out); } diff --git a/tests-clar/object/raw/convert.c b/tests-clar/object/raw/convert.c index 4e7aecf6f..7f310ddf0 100644 --- a/tests-clar/object/raw/convert.c +++ b/tests-clar/object/raw/convert.c @@ -45,7 +45,7 @@ void test_object_raw_convert__succeed_on_oid_to_string_conversion(void) /* returns out as hex formatted c-string */ str = git_oid_tostr(out, sizeof(out), &in); cl_assert(str && str == out && *(str+GIT_OID_HEXSZ) == '\0'); - cl_assert_strequal(exp, out); + cl_assert_equal_s(exp, out); } void test_object_raw_convert__succeed_on_oid_to_string_conversion_big(void) @@ -66,7 +66,7 @@ void test_object_raw_convert__succeed_on_oid_to_string_conversion_big(void) /* returns big as hex formatted c-string */ str = git_oid_tostr(big, sizeof(big), &in); cl_assert(str && str == big && *(str+GIT_OID_HEXSZ) == '\0'); - cl_assert_strequal(exp, big); + cl_assert_equal_s(exp, big); /* check tail material is untouched */ cl_assert(str && str == big && *(str+GIT_OID_HEXSZ+1) == 'X'); diff --git a/tests-clar/object/raw/type2string.c b/tests-clar/object/raw/type2string.c index 2092d2c97..a3585487f 100644 --- a/tests-clar/object/raw/type2string.c +++ b/tests-clar/object/raw/type2string.c @@ -6,19 +6,19 @@ void test_object_raw_type2string__convert_type_to_string(void) { - cl_assert_strequal(git_object_type2string(GIT_OBJ_BAD), ""); - cl_assert_strequal(git_object_type2string(GIT_OBJ__EXT1), ""); - cl_assert_strequal(git_object_type2string(GIT_OBJ_COMMIT), "commit"); - cl_assert_strequal(git_object_type2string(GIT_OBJ_TREE), "tree"); - cl_assert_strequal(git_object_type2string(GIT_OBJ_BLOB), "blob"); - cl_assert_strequal(git_object_type2string(GIT_OBJ_TAG), "tag"); - cl_assert_strequal(git_object_type2string(GIT_OBJ__EXT2), ""); - cl_assert_strequal(git_object_type2string(GIT_OBJ_OFS_DELTA), "OFS_DELTA"); - cl_assert_strequal(git_object_type2string(GIT_OBJ_REF_DELTA), "REF_DELTA"); + cl_assert_equal_s(git_object_type2string(GIT_OBJ_BAD), ""); + cl_assert_equal_s(git_object_type2string(GIT_OBJ__EXT1), ""); + cl_assert_equal_s(git_object_type2string(GIT_OBJ_COMMIT), "commit"); + cl_assert_equal_s(git_object_type2string(GIT_OBJ_TREE), "tree"); + cl_assert_equal_s(git_object_type2string(GIT_OBJ_BLOB), "blob"); + cl_assert_equal_s(git_object_type2string(GIT_OBJ_TAG), "tag"); + cl_assert_equal_s(git_object_type2string(GIT_OBJ__EXT2), ""); + cl_assert_equal_s(git_object_type2string(GIT_OBJ_OFS_DELTA), "OFS_DELTA"); + cl_assert_equal_s(git_object_type2string(GIT_OBJ_REF_DELTA), "REF_DELTA"); - cl_assert_strequal(git_object_type2string(-2), ""); - cl_assert_strequal(git_object_type2string(8), ""); - cl_assert_strequal(git_object_type2string(1234), ""); + cl_assert_equal_s(git_object_type2string(-2), ""); + cl_assert_equal_s(git_object_type2string(8), ""); + cl_assert_equal_s(git_object_type2string(1234), ""); } void test_object_raw_type2string__convert_string_to_type(void) diff --git a/tests-clar/object/tag/read.c b/tests-clar/object/tag/read.c index 2ab31e59d..cfeb3aeee 100644 --- a/tests-clar/object/tag/read.c +++ b/tests-clar/object/tag/read.c @@ -56,7 +56,7 @@ void test_object_tag_read__parse(void) cl_git_pass(git_tag_lookup(&tag1, g_repo, &id1)); - cl_assert_strequal(git_tag_name(tag1), "test"); + cl_assert_equal_s(git_tag_name(tag1), "test"); cl_assert(git_tag_type(tag1) == GIT_OBJ_TAG); cl_git_pass(git_tag_target((git_object **)&tag2, tag1)); @@ -115,7 +115,7 @@ void test_object_tag_read__parse_without_tagger(void) cl_git_pass(git_tag_lookup(&bad_tag, bad_tag_repo, &id)); cl_assert(bad_tag != NULL); - cl_assert_strequal(git_tag_name(bad_tag), "e90810b"); + cl_assert_equal_s(git_tag_name(bad_tag), "e90810b"); cl_assert(git_oid_cmp(&id, git_tag_id(bad_tag)) == 0); cl_assert(bad_tag->tagger == NULL); diff --git a/tests-clar/object/tag/write.c b/tests-clar/object/tag/write.c index 791e1acfa..cb196b64e 100644 --- a/tests-clar/object/tag/write.c +++ b/tests-clar/object/tag/write.c @@ -50,12 +50,12 @@ void test_object_tag_write__basic(void) /* Check attributes were set correctly */ tagger1 = git_tag_tagger(tag); cl_assert(tagger1 != NULL); - cl_assert_strequal(tagger1->name, tagger_name); - cl_assert_strequal(tagger1->email, tagger_email); + cl_assert_equal_s(tagger1->name, tagger_name); + cl_assert_equal_s(tagger1->email, tagger_email); cl_assert(tagger1->when.time == 123456789); cl_assert(tagger1->when.offset == 60); - cl_assert_strequal(git_tag_message(tag), tagger_message); + cl_assert_equal_s(git_tag_message(tag), tagger_message); cl_git_pass(git_reference_lookup(&ref_tag, g_repo, "refs/tags/the-tag")); cl_assert(git_oid_cmp(git_reference_oid(ref_tag), &tag_id) == 0); diff --git a/tests-clar/object/tree/diff.c b/tests-clar/object/tree/diff.c index b664dfdcf..631fc3be4 100644 --- a/tests-clar/object/tree/diff.c +++ b/tests-clar/object/tree/diff.c @@ -18,7 +18,7 @@ static void diff_cmp(const git_tree_diff_data *a, const git_tree_diff_data *b) cl_assert(a->status - b->status == 0); - cl_assert_strequal(a->path, b->path); + cl_assert_equal_s(a->path, b->path); } static int diff_cb(const git_tree_diff_data *diff, void *data) diff --git a/tests-clar/object/tree/read.c b/tests-clar/object/tree/read.c index fc2b44b86..7129a9423 100644 --- a/tests-clar/object/tree/read.c +++ b/tests-clar/object/tree/read.c @@ -65,7 +65,7 @@ void test_object_tree_read__two(void) entry = git_tree_entry_byname(tree, "README"); cl_assert(entry != NULL); - cl_assert_strequal(git_tree_entry_name(entry), "README"); + cl_assert_equal_s(git_tree_entry_name(entry), "README"); cl_git_pass(git_tree_entry_2object(&obj, g_repo, entry)); cl_assert(obj != NULL); diff --git a/tests-clar/refs/create.c b/tests-clar/refs/create.c index 3674022c0..dde4c5745 100644 --- a/tests-clar/refs/create.c +++ b/tests-clar/refs/create.c @@ -42,7 +42,7 @@ void test_refs_create__symbolic(void) cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, new_head_tracker)); cl_assert(git_reference_type(looked_up_ref) & GIT_REF_SYMBOLIC); cl_assert(git_reference_is_packed(looked_up_ref) == 0); - cl_assert_strequal(looked_up_ref->name, new_head_tracker); + cl_assert_equal_s(looked_up_ref->name, new_head_tracker); /* ...peeled.. */ cl_git_pass(git_reference_resolve(&resolved_ref, looked_up_ref)); @@ -112,7 +112,7 @@ void test_refs_create__oid(void) cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, new_head)); cl_assert(git_reference_type(looked_up_ref) & GIT_REF_OID); cl_assert(git_reference_is_packed(looked_up_ref) == 0); - cl_assert_strequal(looked_up_ref->name, new_head); + cl_assert_equal_s(looked_up_ref->name, new_head); /* ...and that it points to the current master tip */ cl_assert(git_oid_cmp(&id, git_reference_oid(looked_up_ref)) == 0); diff --git a/tests-clar/refs/overwrite.c b/tests-clar/refs/overwrite.c index 5c6fd54bd..410e39a84 100644 --- a/tests-clar/refs/overwrite.c +++ b/tests-clar/refs/overwrite.c @@ -34,7 +34,7 @@ void test_refs_overwrite__symbolic(void) /* Ensure it points to the right place*/ cl_git_pass(git_reference_lookup(&ref, g_repo, ref_name)); cl_assert(git_reference_type(ref) & GIT_REF_SYMBOLIC); - cl_assert_strequal(git_reference_target(ref), ref_branch_name); + cl_assert_equal_s(git_reference_target(ref), ref_branch_name); git_reference_free(ref); /* Ensure we can't create it unless we force it to */ @@ -45,7 +45,7 @@ void test_refs_overwrite__symbolic(void) /* Ensure it points to the right place */ cl_git_pass(git_reference_lookup(&ref, g_repo, ref_name)); cl_assert(git_reference_type(ref) & GIT_REF_SYMBOLIC); - cl_assert_strequal(git_reference_target(ref), ref_master_name); + cl_assert_equal_s(git_reference_target(ref), ref_master_name); git_reference_free(ref); git_reference_free(branch_ref); @@ -103,7 +103,7 @@ void test_refs_overwrite__object_id_with_symbolic(void) /* Ensure it points to the right place */ cl_git_pass(git_reference_lookup(&ref, g_repo, ref_name)); cl_assert(git_reference_type(ref) & GIT_REF_SYMBOLIC); - cl_assert_strequal(git_reference_target(ref), ref_master_name); + cl_assert_equal_s(git_reference_target(ref), ref_master_name); git_reference_free(ref); } diff --git a/tests-clar/refs/pack.c b/tests-clar/refs/pack.c index dca83d1ef..d50635670 100644 --- a/tests-clar/refs/pack.c +++ b/tests-clar/refs/pack.c @@ -39,7 +39,7 @@ void test_refs_pack__loose(void) /* Ensure a known loose ref can be looked up */ cl_git_pass(git_reference_lookup(&reference, g_repo, loose_tag_ref_name)); cl_assert(git_reference_is_packed(reference) == 0); - cl_assert_strequal(reference->name, loose_tag_ref_name); + cl_assert_equal_s(reference->name, loose_tag_ref_name); git_reference_free(reference); /* @@ -56,7 +56,7 @@ void test_refs_pack__loose(void) /* Ensure the known ref can still be looked up but is now packed */ cl_git_pass(git_reference_lookup(&reference, g_repo, loose_tag_ref_name)); cl_assert(git_reference_is_packed(reference)); - cl_assert_strequal(reference->name, loose_tag_ref_name); + cl_assert_equal_s(reference->name, loose_tag_ref_name); /* Ensure the known ref has been removed from the loose folder structure */ cl_git_pass(git_buf_joinpath(&temp_path, g_repo->path_repository, loose_tag_ref_name)); diff --git a/tests-clar/refs/read.c b/tests-clar/refs/read.c index c7e88abe4..d7111b232 100644 --- a/tests-clar/refs/read.c +++ b/tests-clar/refs/read.c @@ -34,7 +34,7 @@ void test_refs_read__loose_tag(void) cl_git_pass(git_reference_lookup(&reference, g_repo, loose_tag_ref_name)); cl_assert(git_reference_type(reference) & GIT_REF_OID); cl_assert(git_reference_is_packed(reference) == 0); - cl_assert_strequal(reference->name, loose_tag_ref_name); + cl_assert_equal_s(reference->name, loose_tag_ref_name); cl_git_pass(git_object_lookup(&object, g_repo, git_reference_oid(reference), GIT_OBJ_ANY)); cl_assert(object != NULL); @@ -42,7 +42,7 @@ void test_refs_read__loose_tag(void) /* Ensure the name of the tag matches the name of the reference */ cl_git_pass(git_buf_joinpath(&ref_name_from_tag_name, GIT_REFS_TAGS_DIR, git_tag_name((git_tag *)object))); - cl_assert_strequal(ref_name_from_tag_name.ptr, loose_tag_ref_name); + cl_assert_equal_s(ref_name_from_tag_name.ptr, loose_tag_ref_name); git_buf_free(&ref_name_from_tag_name); git_object_free(object); @@ -71,7 +71,7 @@ void test_refs_read__symbolic(void) cl_git_pass(git_reference_lookup(&reference, g_repo, GIT_HEAD_FILE)); cl_assert(git_reference_type(reference) & GIT_REF_SYMBOLIC); cl_assert(git_reference_is_packed(reference) == 0); - cl_assert_strequal(reference->name, GIT_HEAD_FILE); + cl_assert_equal_s(reference->name, GIT_HEAD_FILE); cl_git_pass(git_reference_resolve(&resolved_ref, reference)); cl_assert(git_reference_type(resolved_ref) == GIT_REF_OID); @@ -99,7 +99,7 @@ void test_refs_read__nested_symbolic(void) cl_git_pass(git_reference_lookup(&reference, g_repo, head_tracker_sym_ref_name)); cl_assert(git_reference_type(reference) & GIT_REF_SYMBOLIC); cl_assert(git_reference_is_packed(reference) == 0); - cl_assert_strequal(reference->name, head_tracker_sym_ref_name); + cl_assert_equal_s(reference->name, head_tracker_sym_ref_name); cl_git_pass(git_reference_resolve(&resolved_ref, reference)); cl_assert(git_reference_type(resolved_ref) == GIT_REF_OID); @@ -167,7 +167,7 @@ void test_refs_read__packed(void) cl_git_pass(git_reference_lookup(&reference, g_repo, packed_head_name)); cl_assert(git_reference_type(reference) & GIT_REF_OID); cl_assert(git_reference_is_packed(reference)); - cl_assert_strequal(reference->name, packed_head_name); + cl_assert_equal_s(reference->name, packed_head_name); cl_git_pass(git_object_lookup(&object, g_repo, git_reference_oid(reference), GIT_OBJ_ANY)); cl_assert(object != NULL); @@ -188,7 +188,7 @@ void test_refs_read__loose_first(void) cl_git_pass(git_reference_lookup(&reference, g_repo, packed_test_head_name)); cl_assert(git_reference_type(reference) & GIT_REF_OID); cl_assert(git_reference_is_packed(reference) == 0); - cl_assert_strequal(reference->name, packed_test_head_name); + cl_assert_equal_s(reference->name, packed_test_head_name); git_reference_free(reference); } diff --git a/tests-clar/refs/reflog.c b/tests-clar/refs/reflog.c index 8000e4851..1bc51b2b8 100644 --- a/tests-clar/refs/reflog.c +++ b/tests-clar/refs/reflog.c @@ -16,8 +16,8 @@ static git_repository *g_repo; static void assert_signature(git_signature *expected, git_signature *actual) { cl_assert(actual); - cl_assert_strequal(expected->name, actual->name); - cl_assert_strequal(expected->email, actual->email); + cl_assert_equal_s(expected->name, actual->name); + cl_assert_equal_s(expected->email, actual->email); cl_assert(expected->when.offset == actual->when.offset); cl_assert(expected->when.time == actual->when.time); } @@ -73,18 +73,18 @@ void test_refs_reflog__write_then_read(void) entry = (git_reflog_entry *)git_vector_get(&reflog->entries, 0); assert_signature(committer, entry->committer); git_oid_tostr(oid_str, GIT_OID_HEXSZ+1, &entry->oid_old); - cl_assert_strequal("0000000000000000000000000000000000000000", oid_str); + cl_assert_equal_s("0000000000000000000000000000000000000000", oid_str); git_oid_tostr(oid_str, GIT_OID_HEXSZ+1, &entry->oid_cur); - cl_assert_strequal(current_master_tip, oid_str); + cl_assert_equal_s(current_master_tip, oid_str); cl_assert(entry->msg == NULL); entry = (git_reflog_entry *)git_vector_get(&reflog->entries, 1); assert_signature(committer, entry->committer); git_oid_tostr(oid_str, GIT_OID_HEXSZ+1, &entry->oid_old); - cl_assert_strequal(current_master_tip, oid_str); + cl_assert_equal_s(current_master_tip, oid_str); git_oid_tostr(oid_str, GIT_OID_HEXSZ+1, &entry->oid_cur); - cl_assert_strequal(current_master_tip, oid_str); - cl_assert_strequal(commit_msg, entry->msg); + cl_assert_equal_s(current_master_tip, oid_str); + cl_assert_equal_s(commit_msg, entry->msg); git_signature_free(committer); git_reflog_free(reflog); diff --git a/tests-clar/refs/rename.c b/tests-clar/refs/rename.c index 8e7c93c97..abcc751ca 100644 --- a/tests-clar/refs/rename.c +++ b/tests-clar/refs/rename.c @@ -48,14 +48,14 @@ void test_refs_rename__loose(void) /* Now that the reference is renamed... */ cl_git_pass(git_reference_rename(looked_up_ref, new_name, 0)); - cl_assert_strequal(looked_up_ref->name, new_name); + cl_assert_equal_s(looked_up_ref->name, new_name); /* ...It can't be looked-up with the old name... */ cl_git_fail(git_reference_lookup(&another_looked_up_ref, g_repo, loose_tag_ref_name)); /* ...but the new name works ok... */ cl_git_pass(git_reference_lookup(&another_looked_up_ref, g_repo, new_name)); - cl_assert_strequal(another_looked_up_ref->name, new_name); + cl_assert_equal_s(another_looked_up_ref->name, new_name); /* .. the ref is still loose... */ cl_assert(git_reference_is_packed(another_looked_up_ref) == 0); @@ -89,14 +89,14 @@ void test_refs_rename__packed(void) /* Now that the reference is renamed... */ cl_git_pass(git_reference_rename(looked_up_ref, brand_new_name, 0)); - cl_assert_strequal(looked_up_ref->name, brand_new_name); + cl_assert_equal_s(looked_up_ref->name, brand_new_name); /* ...It can't be looked-up with the old name... */ cl_git_fail(git_reference_lookup(&another_looked_up_ref, g_repo, packed_head_name)); /* ...but the new name works ok... */ cl_git_pass(git_reference_lookup(&another_looked_up_ref, g_repo, brand_new_name)); - cl_assert_strequal(another_looked_up_ref->name, brand_new_name); + cl_assert_equal_s(another_looked_up_ref->name, brand_new_name); /* .. the ref is no longer packed... */ cl_assert(git_reference_is_packed(another_looked_up_ref) == 0); @@ -166,7 +166,7 @@ void test_refs_rename__name_collision(void) /* Failure to rename it hasn't corrupted its state */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, packed_head_name)); - cl_assert_strequal(looked_up_ref->name, packed_head_name); + cl_assert_equal_s(looked_up_ref->name, packed_head_name); git_reference_free(looked_up_ref); } @@ -188,7 +188,7 @@ void test_refs_rename__invalid_name(void) /* Failure to rename it hasn't corrupted its state */ git_reference_free(looked_up_ref); cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, packed_test_head_name)); - cl_assert_strequal(looked_up_ref->name, packed_test_head_name); + cl_assert_equal_s(looked_up_ref->name, packed_test_head_name); git_reference_free(looked_up_ref); } @@ -209,7 +209,7 @@ void test_refs_rename__force_loose_packed(void) /* Check we actually renamed it */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, packed_test_head_name)); - cl_assert_strequal(looked_up_ref->name, packed_test_head_name); + cl_assert_equal_s(looked_up_ref->name, packed_test_head_name); cl_assert(!git_oid_cmp(&oid, git_reference_oid(looked_up_ref))); git_reference_free(looked_up_ref); @@ -233,7 +233,7 @@ void test_refs_rename__force_loose(void) /* Check we actually renamed it */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, "refs/heads/test")); - cl_assert_strequal(looked_up_ref->name, "refs/heads/test"); + cl_assert_equal_s(looked_up_ref->name, "refs/heads/test"); cl_assert(!git_oid_cmp(&oid, git_reference_oid(looked_up_ref))); git_reference_free(looked_up_ref); @@ -298,7 +298,7 @@ void test_refs_rename__prefix(void) /* Check we actually renamed it */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, ref_two_name_new)); - cl_assert_strequal(looked_up_ref->name, ref_two_name_new); + cl_assert_equal_s(looked_up_ref->name, ref_two_name_new); git_reference_free(looked_up_ref); cl_git_fail(git_reference_lookup(&looked_up_ref, g_repo, ref_two_name)); @@ -331,7 +331,7 @@ void test_refs_rename__move_up(void) /* Check we actually renamed it */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, ref_two_name)); - cl_assert_strequal(looked_up_ref->name, ref_two_name); + cl_assert_equal_s(looked_up_ref->name, ref_two_name); git_reference_free(looked_up_ref); cl_git_fail(git_reference_lookup(&looked_up_ref, g_repo, ref_two_name_new)); git_reference_free(ref); diff --git a/tests-clar/repo/discover.c b/tests-clar/repo/discover.c index 072e3265e..2fbd55f87 100644 --- a/tests-clar/repo/discover.c +++ b/tests-clar/repo/discover.c @@ -30,7 +30,7 @@ static void ensure_repository_discover(const char *start_path, char found_path[GIT_PATH_MAX]; cl_git_pass(git_repository_discover(found_path, sizeof(found_path), start_path, 0, ceiling_dirs)); //across_fs is always 0 as we can't automate the filesystem change tests - cl_assert_strequal(found_path, expected_path); + cl_assert_equal_s(found_path, expected_path); } static void write_file(const char *path, const char *content) @@ -60,10 +60,11 @@ static void append_ceiling_dir(git_buf *ceiling_dirs, const char *path) if (ceiling_dirs->size > 0) git_buf_puts(ceiling_dirs, ceiling_separator); + git_buf_puts(ceiling_dirs, pretty_path.ptr); - - git_buf_free(&pretty_path); - cl_git_pass(git_buf_lasterror(ceiling_dirs)); + + git_buf_free(&pretty_path); + cl_assert(git_buf_oom(ceiling_dirs) == 0); } void test_repo_discover__0(void)