From 9b4bf31231b0a9b40052ad258e9b8e379a27393f Mon Sep 17 00:00:00 2001 From: kares Date: Wed, 10 Apr 2024 18:01:04 +0200 Subject: [PATCH] [test] extra ASN.1 test instantiating with nil --- src/test/ruby/test_asn1.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/test/ruby/test_asn1.rb b/src/test/ruby/test_asn1.rb index f82595fe..98b3240d 100644 --- a/src/test/ruby/test_asn1.rb +++ b/src/test/ruby/test_asn1.rb @@ -45,9 +45,7 @@ def test_constants assert_equal universal_tag_name, OpenSSL::ASN1::UNIVERSAL_TAG_NAME end - require 'pp' - - def _test_parse_infinite_length_sequence # borrowed from Krypt + def _test_parse_infinite_length_sequence; require 'pp' # borrowed from Krypt raw = [%w{30 80 04 01 01 02 01 01 00 00}.join("")].pack("H*") pp asn1 = OpenSSL::ASN1.decode(raw) @@ -66,6 +64,11 @@ def _test_parse_infinite_length_sequence # borrowed from Krypt assert_equal(raw, asn1.to_der) end + def test_simple_to_der + assert_equal "0\x00", OpenSSL::ASN1::Sequence.new(nil).to_der + assert_equal "1\x00", OpenSSL::ASN1::Set.new(nil).to_der + end + def test_constructive oct = OpenSSL::ASN1::OctetString.new("") assert_equal "\x04\x00", oct.to_der