2005-12-17 06:46:23 +00:00
|
|
|
#!/usr/bin/env ruby
|
2005-06-04 19:45:47 +00:00
|
|
|
|
2005-06-09 06:18:27 +00:00
|
|
|
$:.unshift(File.join(File.dirname(__FILE__), '..', '..'))
|
2005-06-04 19:45:47 +00:00
|
|
|
|
|
|
|
require 'test/unit'
|
2005-07-09 21:18:49 +00:00
|
|
|
require 'msf/core/exceptions'
|
2005-06-04 19:45:47 +00:00
|
|
|
|
|
|
|
module Msf
|
|
|
|
module Exceptions
|
|
|
|
|
|
|
|
class UnitTest < Test::Unit::TestCase
|
|
|
|
|
|
|
|
def test_exceptions
|
2005-06-04 21:01:17 +00:00
|
|
|
Msf.constants.each { |const|
|
|
|
|
mod = Msf.const_get(const)
|
|
|
|
|
|
|
|
if ((mod.kind_of?(Class) == false) ||
|
|
|
|
(mod.ancestors.include?(Msf::Exception) == false))
|
|
|
|
next
|
|
|
|
end
|
|
|
|
|
|
|
|
begin
|
|
|
|
raise mod.new
|
|
|
|
rescue mod => detail
|
|
|
|
assert_respond_to(detail, 'to_s', "#{mod} does not implement to_s")
|
|
|
|
assert_not_nil(detail.to_s, "invalid to_s")
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2005-06-04 19:45:47 +00:00
|
|
|
begin
|
|
|
|
raise OptionValidateError.new([ 'test', 'best' ])
|
|
|
|
rescue OptionValidateError => detail
|
|
|
|
assert_match(/^The following/, detail.to_s)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|