summaryrefslogtreecommitdiff
path: root/lib/util/tests
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamen.mazdrashki@postpath.com>2009-09-26 01:25:28 +0300
committerMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>2009-10-01 23:12:59 +0200
commit5021301a0e6a15de5552583b1ffeb66619d398d8 (patch)
tree4a96fbac93a9f360f9f2aa40e72cd71656b2fba4 /lib/util/tests
parent681064e66e8146518be42393ecb58baa94d6a913 (diff)
downloadsamba-5021301a0e6a15de5552583b1ffeb66619d398d8.tar.gz
samba-5021301a0e6a15de5552583b1ffeb66619d398d8.tar.bz2
samba-5021301a0e6a15de5552583b1ffeb66619d398d8.zip
s4/asn1: Added test for ber_read_OID_String()
Diffstat (limited to 'lib/util/tests')
-rw-r--r--lib/util/tests/asn1_tests.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/util/tests/asn1_tests.c b/lib/util/tests/asn1_tests.c
index f23efeea87..633a9346b4 100644
--- a/lib/util/tests/asn1_tests.c
+++ b/lib/util/tests/asn1_tests.c
@@ -122,6 +122,34 @@ static bool test_ber_write_OID_String(struct torture_context *tctx)
return true;
}
+/* Testing ber_read_OID_String() function */
+static bool test_ber_read_OID_String(struct torture_context *tctx)
+{
+ int i;
+ const char *oid;
+ DATA_BLOB oid_blob;
+ TALLOC_CTX *mem_ctx;
+ struct oid_data *data = oid_data_ok;
+
+ mem_ctx = talloc_new(tctx);
+
+ for (i = 0; i < ARRAY_SIZE(oid_data_ok); i++) {
+ oid_blob = strhex_to_data_blob(mem_ctx, data[i].bin_oid);
+
+ torture_assert(tctx, ber_read_OID_String(mem_ctx, oid_blob, &oid),
+ "ber_read_OID_String failed");
+
+ torture_assert(tctx, strequal(data[i].oid, oid),
+ talloc_asprintf(mem_ctx,
+ "Failed: oid=%s, bin_oid:%s",
+ data[i].oid, data[i].bin_oid));
+ }
+
+ talloc_free(mem_ctx);
+
+ return true;
+}
+
/* Testing ber_write_partial_OID_String() function */
static bool test_ber_write_partial_OID_String(struct torture_context *tctx)
{
@@ -168,6 +196,7 @@ static bool test_ber_write_partial_OID_String(struct torture_context *tctx)
}
+
/* LOCAL-ASN1 test suite creation */
struct torture_suite *torture_local_util_asn1(TALLOC_CTX *mem_ctx)
{
@@ -176,6 +205,9 @@ struct torture_suite *torture_local_util_asn1(TALLOC_CTX *mem_ctx)
torture_suite_add_simple_test(suite, "ber_write_OID_String",
test_ber_write_OID_String);
+ torture_suite_add_simple_test(suite, "ber_read_OID_String",
+ test_ber_read_OID_String);
+
torture_suite_add_simple_test(suite, "ber_write_partial_OID_String",
test_ber_write_partial_OID_String);