summaryrefslogtreecommitdiff
path: root/tests/libgit2/refs/dup.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/libgit2/refs/dup.c')
-rw-r--r--tests/libgit2/refs/dup.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/libgit2/refs/dup.c b/tests/libgit2/refs/dup.c
new file mode 100644
index 000000000..8a89cd95c
--- /dev/null
+++ b/tests/libgit2/refs/dup.c
@@ -0,0 +1,42 @@
+#include "clar_libgit2.h"
+#include "refs.h"
+
+static git_repository *g_repo;
+
+void test_refs_dup__initialize(void)
+{
+ g_repo = cl_git_sandbox_init("testrepo.git");
+}
+
+void test_refs_dup__cleanup(void)
+{
+ cl_git_sandbox_cleanup();
+}
+
+void test_refs_dup__direct(void)
+{
+ git_reference *a, *b;
+
+ cl_git_pass(git_reference_lookup(&a, g_repo, "refs/heads/master"));
+ cl_git_pass(git_reference_dup(&b, a));
+
+ cl_assert(git_reference_cmp(a, b) == 0);
+ cl_assert(git_reference_owner(b) == g_repo);
+
+ git_reference_free(b);
+ git_reference_free(a);
+}
+
+void test_refs_dup__symbolic(void)
+{
+ git_reference *a, *b;
+
+ cl_git_pass(git_reference_lookup(&a, g_repo, "HEAD"));
+ cl_git_pass(git_reference_dup(&b, a));
+
+ cl_assert(git_reference_cmp(a, b) == 0);
+ cl_assert(git_reference_owner(b) == g_repo);
+
+ git_reference_free(b);
+ git_reference_free(a);
+}