[glib: 1/4] tests/tls-certificate: Change to g_assert_null/nonnull
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/4] tests/tls-certificate: Change to g_assert_null/nonnull
- Date: Wed, 19 Dec 2018 11:53:33 +0000 (UTC)
commit c7ee5221728509f2603dd4b8ceac4e581693209e
Author: Fredrik Ternerot <fredrikt axis com>
Date: Tue Dec 18 10:39:01 2018 +0100
tests/tls-certificate: Change to g_assert_null/nonnull
Use g_assert_null/g_assert_nonnull instead of g_assert since
g_assert can be compiled out with G_DISABLE_ASSERT.
gio/tests/tls-certificate.c | 54 ++++++++++++++++++++++-----------------------
1 file changed, 27 insertions(+), 27 deletions(-)
---
diff --git a/gio/tests/tls-certificate.c b/gio/tests/tls-certificate.c
index db2511f59..39e9c77df 100644
--- a/gio/tests/tls-certificate.c
+++ b/gio/tests/tls-certificate.c
@@ -44,12 +44,12 @@ pem_parser (const Reference *ref)
/* Check PEM parsing in certificate, private key order. */
g_file_get_contents (g_test_get_filename (G_TEST_DIST, "cert-tests", "cert-key.pem", NULL), &pem,
&pem_len, &error);
g_assert_no_error (error);
- g_assert (pem);
+ g_assert_nonnull (pem);
g_assert_cmpuint (pem_len, >=, 10);
cert = g_tls_certificate_new_from_pem (pem, -1, &error);
g_assert_no_error (error);
- g_assert (cert);
+ g_assert_nonnull (cert);
g_object_get (cert,
"certificate-pem", &parsed_cert_pem,
@@ -79,11 +79,11 @@ pem_parser (const Reference *ref)
/* Check PEM parsing in private key, certificate order */
g_file_get_contents (g_test_get_filename (G_TEST_DIST, "cert-tests", "key-cert.pem", NULL), &pem, NULL,
&error);
g_assert_no_error (error);
- g_assert (pem);
+ g_assert_nonnull (pem);
cert = g_tls_certificate_new_from_pem (pem, -1, &error);
g_assert_no_error (error);
- g_assert (cert);
+ g_assert_nonnull (cert);
g_object_get (cert,
"certificate-pem", &parsed_cert_pem,
@@ -101,11 +101,11 @@ pem_parser (const Reference *ref)
/* Check certificate only PEM */
g_file_get_contents (g_test_get_filename (G_TEST_DIST, "cert-tests", "cert1.pem", NULL), &pem, NULL,
&error);
g_assert_no_error (error);
- g_assert (pem);
+ g_assert_nonnull (pem);
cert = g_tls_certificate_new_from_pem (pem, -1, &error);
g_assert_no_error (error);
- g_assert (cert);
+ g_assert_nonnull (cert);
g_object_get (cert,
"certificate-pem", &parsed_cert_pem,
@@ -114,7 +114,7 @@ pem_parser (const Reference *ref)
g_assert_cmpstr (parsed_cert_pem, ==, ref->cert_pems[0]);
g_free (parsed_cert_pem);
parsed_cert_pem = NULL;
- g_assert (parsed_key_pem == NULL);
+ g_assert_null (parsed_key_pem);
g_free (pem);
g_object_unref (cert);
@@ -122,12 +122,12 @@ pem_parser (const Reference *ref)
/* Check error with private key only PEM */
g_file_get_contents (g_test_get_filename (G_TEST_DIST, "cert-tests", "key.pem", NULL), &pem, NULL, &error);
g_assert_no_error (error);
- g_assert (pem);
+ g_assert_nonnull (pem);
cert = g_tls_certificate_new_from_pem (pem, -1, &error);
g_assert_error (error, G_TLS_ERROR, G_TLS_ERROR_BAD_CERTIFICATE);
g_clear_error (&error);
- g_assert (cert == NULL);
+ g_assert_null (cert);
g_free (pem);
}
@@ -145,12 +145,12 @@ pem_parser_handles_chain (const Reference *ref)
/* Check that a chain with exactly three certificates is returned */
g_file_get_contents (g_test_get_filename (G_TEST_DIST, "cert-tests", "cert-list.pem", NULL), &pem, NULL,
&error);
g_assert_no_error (error);
- g_assert (pem);
+ g_assert_nonnull (pem);
cert = original_cert = g_tls_certificate_new_from_pem (pem, -1, &error);
g_free (pem);
g_assert_no_error (error);
- g_assert (cert);
+ g_assert_nonnull (cert);
g_object_get (cert,
"certificate-pem", &parsed_cert_pem,
@@ -165,11 +165,11 @@ pem_parser_handles_chain (const Reference *ref)
/* Now test the second cert */
issuer = g_tls_certificate_get_issuer (cert);
- g_assert (issuer);
+ g_assert_nonnull (issuer);
cert = issuer;
issuer = g_tls_certificate_get_issuer (cert);
- g_assert (issuer);
+ g_assert_nonnull (issuer);
g_object_get (cert,
"certificate-pem", &parsed_cert_pem,
@@ -179,12 +179,12 @@ pem_parser_handles_chain (const Reference *ref)
/* Only the first cert should have a private key */
parsed_key_pem = g_test_tls_connection_get_private_key_pem (cert);
- g_assert (!parsed_key_pem);
+ g_assert_null (parsed_key_pem);
/* Now test the final cert */
cert = issuer;
issuer = g_tls_certificate_get_issuer (cert);
- g_assert (!issuer);
+ g_assert_null (issuer);
g_object_get (cert,
"certificate-pem", &parsed_cert_pem,
@@ -193,7 +193,7 @@ pem_parser_handles_chain (const Reference *ref)
g_clear_pointer (&parsed_cert_pem, g_free);
parsed_key_pem = g_test_tls_connection_get_private_key_pem (cert);
- g_assert (!parsed_key_pem);
+ g_assert_null (parsed_key_pem);
g_object_unref (original_cert);
}
@@ -209,7 +209,7 @@ from_file (const Reference *ref)
cert = g_tls_certificate_new_from_file (g_test_get_filename (G_TEST_DIST, "cert-tests", "key-cert.pem",
NULL),
&error);
g_assert_no_error (error);
- g_assert (cert);
+ g_assert_nonnull (cert);
g_object_get (cert,
"certificate-pem", &parsed_cert_pem,
@@ -236,7 +236,7 @@ from_files (const Reference *ref)
g_test_get_filename (G_TEST_DIST, "cert-tests", "key.pem", NULL),
&error);
g_assert_no_error (error);
- g_assert (cert);
+ g_assert_nonnull (cert);
g_object_get (cert,
"certificate-pem", &parsed_cert_pem,
@@ -256,7 +256,7 @@ from_files (const Reference *ref)
&error);
g_assert_error (error, G_TLS_ERROR, G_TLS_ERROR_BAD_CERTIFICATE);
g_clear_error (&error);
- g_assert (cert == NULL);
+ g_assert_null (cert);
/* Missing certificate */
cert = g_tls_certificate_new_from_files (g_test_get_filename (G_TEST_DIST, "cert-tests", "key.pem", NULL),
@@ -264,7 +264,7 @@ from_files (const Reference *ref)
&error);
g_assert_error (error, G_TLS_ERROR, G_TLS_ERROR_BAD_CERTIFICATE);
g_clear_error (&error);
- g_assert (cert == NULL);
+ g_assert_null (cert);
/* Using this method twice with a file containing both private key and
* certificate as a way to inforce private key presence is a fair use
@@ -273,7 +273,7 @@ from_files (const Reference *ref)
g_test_get_filename (G_TEST_DIST, "cert-tests", "key-cert.pem",
NULL),
&error);
g_assert_no_error (error);
- g_assert (cert);
+ g_assert_nonnull (cert);
g_object_unref (cert);
}
@@ -290,7 +290,7 @@ from_files_pkcs8 (const Reference *ref)
g_test_get_filename (G_TEST_DIST, "cert-tests", "key8.pem", NULL),
&error);
g_assert_no_error (error);
- g_assert (cert);
+ g_assert_nonnull (cert);
g_object_get (cert,
"certificate-pem", &parsed_cert_pem,
@@ -356,27 +356,27 @@ main (int argc,
path = g_test_build_filename (G_TEST_DIST, "cert-tests", "cert1.pem", NULL);
g_file_get_contents (path, &ref.cert_pems[0], NULL, &error);
g_assert_no_error (error);
- g_assert (ref.cert_pems[0]);
+ g_assert_nonnull (ref.cert_pems[0]);
g_free (path);
path = g_test_build_filename (G_TEST_DIST, "cert-tests", "cert2.pem", NULL);
g_file_get_contents (path, &ref.cert_pems[1], NULL, &error);
g_assert_no_error (error);
- g_assert (ref.cert_pems[1]);
+ g_assert_nonnull (ref.cert_pems[1]);
g_free (path);
path = g_test_build_filename (G_TEST_DIST, "cert-tests", "cert3.pem", NULL);
g_file_get_contents (path, &ref.cert_pems[2], NULL, &error);
g_assert_no_error (error);
- g_assert (ref.cert_pems[2]);
+ g_assert_nonnull (ref.cert_pems[2]);
g_free (path);
path = g_test_build_filename (G_TEST_DIST, "cert-tests", "key.pem", NULL);
g_file_get_contents (path, &ref.key_pem, NULL, &error);
g_assert_no_error (error);
- g_assert (ref.key_pem);
+ g_assert_nonnull (ref.key_pem);
g_free (path);
path = g_test_build_filename (G_TEST_DIST, "cert-tests", "key8.pem", NULL);
g_file_get_contents (path, &ref.key8_pem, NULL, &error);
g_assert_no_error (error);
- g_assert (ref.key8_pem);
+ g_assert_nonnull (ref.key8_pem);
g_free (path);
g_test_add_data_func ("/tls-certificate/pem-parser",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]