2005-12-17 06:46:23 +00:00
|
|
|
#!/usr/bin/env ruby
|
2005-07-07 14:20:54 +00:00
|
|
|
|
|
|
|
$:.unshift(File.join(File.dirname(__FILE__), '..', '..', '..'))
|
|
|
|
|
|
|
|
require 'test/unit'
|
2005-07-09 21:18:49 +00:00
|
|
|
require 'rex/ui/text/table'
|
2005-07-07 14:20:54 +00:00
|
|
|
|
|
|
|
class Rex::Ui::Text::Table::UnitTest < Test::Unit::TestCase
|
|
|
|
|
|
|
|
def new_table(opts = {})
|
|
|
|
if (opts['Columns'] == nil)
|
|
|
|
opts['Columns'] =
|
|
|
|
[
|
|
|
|
'col1',
|
|
|
|
'col2',
|
|
|
|
'col3'
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
tbl = Rex::Ui::Text::Table.new(opts)
|
|
|
|
|
|
|
|
tbl << [ "r1cell1", "r1cell2", "r1cell3" ]
|
|
|
|
tbl << [ "r2cell1", "r2cell2", "r2cell3" ]
|
|
|
|
|
|
|
|
return tbl
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_basic
|
|
|
|
tbl = new_table
|
|
|
|
|
|
|
|
dstr = <<End
|
|
|
|
col1 col2 col3
|
|
|
|
---- ---- ----
|
|
|
|
r1cell1 r1cell2 r1cell3
|
|
|
|
r2cell1 r2cell2 r2cell3
|
|
|
|
End
|
|
|
|
|
|
|
|
assert_equal(tbl.to_s, dstr)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_indent
|
|
|
|
tbl = new_table(
|
|
|
|
'Indent' => 4)
|
|
|
|
|
|
|
|
dstr = <<End
|
2006-01-28 01:23:46 +00:00
|
|
|
col1 col2 col3
|
|
|
|
---- ---- ----
|
|
|
|
r1cell1 r1cell2 r1cell3
|
|
|
|
r2cell1 r2cell2 r2cell3
|
2005-07-07 14:20:54 +00:00
|
|
|
End
|
|
|
|
|
|
|
|
assert_equal(tbl.to_s, dstr)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|