PageRenderTime 40ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/rex/ui/text/table.rb.ut.rb

https://bitbucket.org/technopunk2099/metasploit-framework
Ruby | 56 lines | 40 code | 14 blank | 2 comment | 2 complexity | 861e86cb7ac29eb58c78aebcf31bf3db MD5 | raw file
Possible License(s): BSD-3-Clause, Apache-2.0, LGPL-2.1, GPL-2.0, MIT
  1. #!/usr/bin/env ruby
  2. # -*- coding: binary -*-
  3. $:.unshift(File.join(File.dirname(__FILE__), '..', '..', '..'))
  4. require 'test/unit'
  5. require 'rex/ui/text/table'
  6. class Rex::Ui::Text::Table::UnitTest < Test::Unit::TestCase
  7. def new_table(opts = {})
  8. if (opts['Columns'] == nil)
  9. opts['Columns'] =
  10. [
  11. 'col1',
  12. 'col2',
  13. 'col3'
  14. ]
  15. end
  16. tbl = Rex::Ui::Text::Table.new(opts)
  17. tbl << [ "r1cell1", "r1cell2", "r1cell3" ]
  18. tbl << [ "r2cell1", "r2cell2", "r2cell3" ]
  19. return tbl
  20. end
  21. def test_basic
  22. tbl = new_table
  23. dstr = <<End
  24. col1 col2 col3
  25. ---- ---- ----
  26. r1cell1 r1cell2 r1cell3
  27. r2cell1 r2cell2 r2cell3
  28. End
  29. assert_equal(tbl.to_s, dstr)
  30. end
  31. def test_indent
  32. tbl = new_table(
  33. 'Indent' => 4)
  34. dstr = <<End
  35. col1 col2 col3
  36. ---- ---- ----
  37. r1cell1 r1cell2 r1cell3
  38. r2cell1 r2cell2 r2cell3
  39. End
  40. assert_equal(tbl.to_s, dstr)
  41. end
  42. end