blob: d6281227e0efa4c16cc079d5f5274035cadaae3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
require "asn1kit"
require "test/unit"
require "pp"
class ASN1KitTestCase < Test::Unit::TestCase
def B(ary)
[ary.join].pack("H*")
end
def assert_raise_with_message(exception, pattern, msg = nil, &block)
unless pattern.is_a?(String) or pattern.is_a?(Regexp)
raise TypeError, "expected message must be a kind of String or Regexp"
end
msg ||= "Exception %s with message %p is raised" % [exception, pattern]
raised = assert_raise(exception, msg) { yield }
if pattern.is_a?(Regexp)
assert_match(pattern, raised.message, msg)
else
assert_equal(pattern, raised.message, msg)
end
raised
end
end
|