summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2014-03-24 17:48:54 -0700
committerEdward Thomson <ethomson@microsoft.com>2014-03-25 21:54:41 -0700
commitf2f2d97f1e5264c061177a1c64fa6b3420a95188 (patch)
tree21507786ce22ee3e400e0c19d18a02f652535e2b
parent451aaf866af2d974380a2d141626f450212f40f2 (diff)
downloadlibgit2-f2f2d97f1e5264c061177a1c64fa6b3420a95188.tar.gz
Test for giterr_capture
-rw-r--r--tests/core/errors.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/core/errors.c b/tests/core/errors.c
index 512a4134d..366d8f16a 100644
--- a/tests/core/errors.c
+++ b/tests/core/errors.c
@@ -85,3 +85,27 @@ void test_core_errors__new_school(void)
giterr_clear();
}
+
+void test_core_errors__restore(void)
+{
+ git_error_state err_state = {0};
+
+ giterr_clear();
+ cl_assert(giterr_last() == NULL);
+
+ cl_assert_equal_i(0, giterr_capture(&err_state, 0));
+
+ memset(&err_state, 0x0, sizeof(git_error_state));
+
+ giterr_set(42, "Foo: %s", "bar");
+ cl_assert_equal_i(-1, giterr_capture(&err_state, -1));
+
+ cl_assert(giterr_last() == NULL);
+
+ giterr_set(99, "Bar: %s", "foo");
+
+ giterr_restore(&err_state);
+
+ cl_assert_equal_i(42, giterr_last()->klass);
+ cl_assert_equal_s("Foo: bar", giterr_last()->message);
+}