aboutsummaryrefslogtreecommitdiffstats
path: root/t/unit-tests
diff options
context:
space:
mode:
authorChandra Pratap <chandrapratap3519@gmail.com>2024-07-02 12:52:23 +0530
committerJunio C Hamano <gitster@pobox.com>2024-07-02 08:12:26 -0700
commitf7ec13b53896966c233514c3906c284a40b00c3c (patch)
tree9b9feb18c3bb00dca2820862cf44c3cf4aa1c736 /t/unit-tests
parent8a1f1f88bbcac191d5904fd966e6a767caf97d4b (diff)
downloadgit-f7ec13b53896966c233514c3906c284a40b00c3c.tar.gz
t-reftable-record: add tests for reftable_ref_record_compare_name()
reftable_ref_record_compare_name() is a function defined by reftable/record.{c, h} and is used to compare the refname of two ref records when sorting multiple ref records using 'qsort'. In the current testing setup, this function is left unexercised. Add a testing function for the same. Mentored-by: Patrick Steinhardt <ps@pks.im> Mentored-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com> Acked-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/unit-tests')
-rw-r--r--t/unit-tests/t-reftable-record.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/t/unit-tests/t-reftable-record.c b/t/unit-tests/t-reftable-record.c
index 43b5d40899..c0668cd8b4 100644
--- a/t/unit-tests/t-reftable-record.c
+++ b/t/unit-tests/t-reftable-record.c
@@ -95,6 +95,25 @@ static void t_reftable_ref_record_comparison(void)
check(!reftable_record_cmp(&in[0], &in[1]));
}
+static void t_reftable_ref_record_compare_name(void)
+{
+ struct reftable_ref_record recs[3] = {
+ {
+ .refname = (char *) "refs/heads/a"
+ },
+ {
+ .refname = (char *) "refs/heads/b"
+ },
+ {
+ .refname = (char *) "refs/heads/a"
+ },
+ };
+
+ check_int(reftable_ref_record_compare_name(&recs[0], &recs[1]), <, 0);
+ check_int(reftable_ref_record_compare_name(&recs[1], &recs[0]), >, 0);
+ check_int(reftable_ref_record_compare_name(&recs[0], &recs[2]), ==, 0);
+}
+
static void t_reftable_ref_record_roundtrip(void)
{
struct strbuf scratch = STRBUF_INIT;
@@ -490,6 +509,7 @@ int cmd_main(int argc, const char *argv[])
TEST(t_reftable_log_record_comparison(), "comparison operations work on log record");
TEST(t_reftable_index_record_comparison(), "comparison operations work on index record");
TEST(t_reftable_obj_record_comparison(), "comparison operations work on obj record");
+ TEST(t_reftable_ref_record_compare_name(), "reftable_ref_record_compare_name works");
TEST(t_reftable_log_record_roundtrip(), "record operations work on log record");
TEST(t_reftable_ref_record_roundtrip(), "record operations work on ref record");
TEST(t_varint_roundtrip(), "put_var_int and get_var_int work");