summaryrefslogtreecommitdiff
path: root/tests-clar/checkout/index.c
diff options
context:
space:
mode:
authorBen Straub <bs@github.com>2012-11-29 14:06:40 -0800
committerBen Straub <bs@github.com>2012-11-30 13:12:14 -0800
commitb81aa2f1deb98eb7f9e60ac96696e69a9a49d8f8 (patch)
treec9319fc7252b87c183dc6d7ed9296c0e48f50f5a /tests-clar/checkout/index.c
parentf4fc9fdba03dd4975229243d7c1debd00c9d1f18 (diff)
downloadlibgit2-b81aa2f1deb98eb7f9e60ac96696e69a9a49d8f8.tar.gz
Deploy GIT_CHECKOUT_OPTS_INIT
Diffstat (limited to 'tests-clar/checkout/index.c')
-rw-r--r--tests-clar/checkout/index.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/tests-clar/checkout/index.c b/tests-clar/checkout/index.c
index b6d637223..e86dfe954 100644
--- a/tests-clar/checkout/index.c
+++ b/tests-clar/checkout/index.c
@@ -2,6 +2,7 @@
#include "git2/checkout.h"
#include "repository.h"
+#include "checkout_util.h"
static git_repository *g_repo;
static git_checkout_opts g_opts;
@@ -25,7 +26,7 @@ void test_checkout_index__initialize(void)
{
git_tree *tree;
- memset(&g_opts, 0, sizeof(g_opts));
+ reset_checkout_opts(&g_opts);
g_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
g_repo = cl_git_sandbox_init("testrepo");
@@ -66,7 +67,7 @@ void test_checkout_index__cannot_checkout_a_bare_repository(void)
{
test_checkout_index__cleanup();
- memset(&g_opts, 0, sizeof(g_opts));
+ reset_checkout_opts(&g_opts);
g_repo = cl_git_sandbox_init("testrepo.git");
cl_git_fail(git_checkout_index(g_repo, NULL, NULL));
@@ -426,3 +427,21 @@ void test_checkout_index__can_overcome_name_clashes(void)
git_index_free(index);
}
+
+void test_checkout_index__validates_struct_version(void)
+{
+ const git_error *err;
+
+ g_opts.version = 1024;
+ cl_git_fail(git_checkout_index(g_repo, NULL, &g_opts));
+
+ err = giterr_last();
+ cl_assert_equal_i(err->klass, GITERR_INVALID);
+
+ g_opts.version = 0;
+ giterr_clear();
+ cl_git_fail(git_checkout_index(g_repo, NULL, &g_opts));
+
+ err = giterr_last();
+ cl_assert_equal_i(err->klass, GITERR_INVALID);
+}