[gnome-keyring/trust-store: 103/105] [egg] Add functions testing ASN.1 and printing out messages.



commit ca9961d8b2204ba15155e148d41ba7664356164e
Author: Stef Walter <stefw collabora co uk>
Date:   Tue Nov 23 02:26:23 2010 +0000

    [egg] Add functions testing ASN.1 and printing out messages.

 egg/egg-asn1x.h            |   11 +++++++++++
 egg/tests/unit-test-asn1.c |    5 ++++-
 2 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/egg/egg-asn1x.h b/egg/egg-asn1x.h
index 21029ef..f987f9d 100644
--- a/egg/egg-asn1x.h
+++ b/egg/egg-asn1x.h
@@ -190,4 +190,15 @@ gconstpointer       egg_asn1x_element_content        (gconstpointer data,
                                                       gsize n_data,
                                                       gsize *n_content);
 
+#define             egg_asn1x_assert(expr, node) \
+	do { if G_LIKELY(expr) ; else \
+		g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
+		                     egg_asn1x_message (node) ? \
+		                     egg_asn1x_message (node) : "[no message]"); } while(0)
+
+#define             egg_asn1x_assert_not_reached(node) \
+		g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
+		                     egg_asn1x_message (node) ? \
+		                     egg_asn1x_message (node) : "[no message]")
+
 #endif /*EGG_ASN1X_H_*/
diff --git a/egg/tests/unit-test-asn1.c b/egg/tests/unit-test-asn1.c
index b01ae23..c4171d4 100644
--- a/egg/tests/unit-test-asn1.c
+++ b/egg/tests/unit-test-asn1.c
@@ -47,8 +47,11 @@ DEFINE_SETUP(asn1_tree)
 {
 	data_cert = testing_data_read ("test-certificate-1.der", &n_data_cert);
 
-	asn1_cert = egg_asn1x_create_and_decode (pkix_asn1_tab, "Certificate", data_cert, n_data_cert);
+	asn1_cert = egg_asn1x_create (pkix_asn1_tab, "Certificate");
 	g_assert (asn1_cert != NULL);
+
+	if (!egg_asn1x_decode (asn1_cert, data_cert, n_data_cert))
+		egg_asn1x_assert_not_reached (asn1_cert);
 }
 
 DEFINE_TEARDOWN(asn1_tree)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]