summaryrefslogtreecommitdiff
path: root/tests/core
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2018-11-22 08:49:09 +0000
committerEdward Thomson <ethomson@edwardthomson.com>2018-11-28 15:50:15 +0000
commit02bb39f448b9ed151a638d22fdcbccc895f4d3cf (patch)
tree5b17db72f1b12951e08d6ae2e5179eb40fcac2eb /tests/core
parent52478d7dc323ad1768bc5c6fc03c031b7adc5d20 (diff)
downloadlibgit2-02bb39f448b9ed151a638d22fdcbccc895f4d3cf.tar.gz
stream registration: take an enum type
Accept an enum (`git_stream_t`) during custom stream registration that indicates whether the registration structure should be used for standard (non-TLS) streams or TLS streams.
Diffstat (limited to 'tests/core')
-rw-r--r--tests/core/stream.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/tests/core/stream.c b/tests/core/stream.c
index a76169d48..f15dce3cd 100644
--- a/tests/core/stream.c
+++ b/tests/core/stream.c
@@ -7,6 +7,11 @@
static git_stream test_stream;
static int ctor_called;
+void test_core_stream__cleanup(void)
+{
+ cl_git_pass(git_stream_register(GIT_STREAM_TLS | GIT_STREAM_STANDARD, NULL));
+}
+
static int test_stream_init(git_stream **out, const char *host, const char *port)
{
GIT_UNUSED(host);
@@ -39,14 +44,14 @@ void test_core_stream__register_insecure(void)
registration.wrap = test_stream_wrap;
ctor_called = 0;
- cl_git_pass(git_stream_register(0, &registration));
+ cl_git_pass(git_stream_register(GIT_STREAM_STANDARD, &registration));
cl_git_pass(git_socket_stream_new(&stream, "localhost", "80"));
cl_assert_equal_i(1, ctor_called);
cl_assert_equal_p(&test_stream, stream);
ctor_called = 0;
stream = NULL;
- cl_git_pass(git_stream_register(0, NULL));
+ cl_git_pass(git_stream_register(GIT_STREAM_STANDARD, NULL));
cl_git_pass(git_socket_stream_new(&stream, "localhost", "80"));
cl_assert_equal_i(0, ctor_called);
@@ -66,14 +71,14 @@ void test_core_stream__register_tls(void)
registration.wrap = test_stream_wrap;
ctor_called = 0;
- cl_git_pass(git_stream_register(1, &registration));
+ cl_git_pass(git_stream_register(GIT_STREAM_TLS, &registration));
cl_git_pass(git_tls_stream_new(&stream, "localhost", "443"));
cl_assert_equal_i(1, ctor_called);
cl_assert_equal_p(&test_stream, stream);
ctor_called = 0;
stream = NULL;
- cl_git_pass(git_stream_register(1, NULL));
+ cl_git_pass(git_stream_register(GIT_STREAM_TLS, NULL));
error = git_tls_stream_new(&stream, "localhost", "443");
/* We don't have TLS support enabled, or we're on Windows,
@@ -91,6 +96,28 @@ void test_core_stream__register_tls(void)
git_stream_free(stream);
}
+void test_core_stream__register_both(void)
+{
+ git_stream *stream;
+ git_stream_registration registration = {0};
+
+ registration.version = 1;
+ registration.init = test_stream_init;
+ registration.wrap = test_stream_wrap;
+
+ cl_git_pass(git_stream_register(GIT_STREAM_STANDARD | GIT_STREAM_TLS, &registration));
+
+ ctor_called = 0;
+ cl_git_pass(git_tls_stream_new(&stream, "localhost", "443"));
+ cl_assert_equal_i(1, ctor_called);
+ cl_assert_equal_p(&test_stream, stream);
+
+ ctor_called = 0;
+ cl_git_pass(git_socket_stream_new(&stream, "localhost", "80"));
+ cl_assert_equal_i(1, ctor_called);
+ cl_assert_equal_p(&test_stream, stream);
+}
+
void test_core_stream__register_tls_deprecated(void)
{
git_stream *stream;