Class: Rex::Ui::Text::Table::UnitTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/rex/ui/text/table.rb.ut.rb

Instance Method Summary collapse

Instance Method Details

#new_table(opts = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rex/ui/text/table.rb.ut.rb', line 11

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

#test_basicObject



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rex/ui/text/table.rb.ut.rb', line 29

def test_basic
  tbl = new_table

  dstr = "col1     col2     col3     \n----     ----     ----     \nr1cell1  r1cell2  r1cell3  \nr2cell1  r2cell2  r2cell3  \n" 

  assert_equal(tbl.to_s, dstr)
end

#test_indentObject



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rex/ui/text/table.rb.ut.rb', line 42

def test_indent
  tbl = new_table(
    'Indent' => 4)

  dstr = "   col1     col2     col3     \n   ----     ----     ----     \n   r1cell1  r1cell2  r1cell3  \n   r2cell1  r2cell2  r2cell3  \n" 

  assert_equal(tbl.to_s, dstr)
end