Feature #4116 ยป ossl_x509name.c.comparable.patch
ext/openssl/ossl_x509name.c (working copy) | ||
---|---|---|
return X509_NAME_cmp(name1, name2);
|
||
}
|
||
/*
|
||
* call-seq:
|
||
* name.cmp other => integer
|
||
* name.<=> other => integer
|
||
*
|
||
* Compares this Name with +other+ and returns 0 if they are the same and -1 or
|
||
* +1 if they are greater or less than each other respectively.
|
||
*/
|
||
static VALUE
|
||
ossl_x509name_cmp(VALUE self, VALUE other)
|
||
{
|
||
... | ... | |
eX509NameError = rb_define_class_under(mX509, "NameError", eOSSLError);
|
||
cX509Name = rb_define_class_under(mX509, "Name", rb_cObject);
|
||
rb_include_module(cX509Name, rb_mComparable);
|
||
rb_define_alloc_func(cX509Name, ossl_x509name_alloc);
|
||
rb_define_method(cX509Name, "initialize", ossl_x509name_initialize, -1);
|
||
rb_define_method(cX509Name, "add_entry", ossl_x509name_add_entry, -1);
|
test/openssl/test_x509name.rb (working copy) | ||
---|---|---|
assert_equal(OpenSSL::ASN1::IA5STRING, ary[3][2])
|
||
assert_equal(OpenSSL::ASN1::PRINTABLESTRING, ary[4][2])
|
||
end
|
||
def test_equals2
|
||
n1 = OpenSSL::X509::Name.parse 'CN=a'
|
||
n2 = OpenSSL::X509::Name.parse 'CN=a'
|
||
assert_equal n1, n2
|
||
end
|
||
def test_spaceship
|
||
n1 = OpenSSL::X509::Name.parse 'CN=a'
|
||
n2 = OpenSSL::X509::Name.parse 'CN=b'
|
||
assert_equal -1, n1 <=> n2
|
||
end
|
||
end
|
||
end
|