PageRenderTime 208ms CodeModel.GetById 89ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/technopunk2099/metasploit-framework
Ruby | 35 lines | 25 code | 8 blank | 2 comment | 0 complexity | c44c540346fbfa2a47ac6f543c1eb1d7 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'
  6. class Rex::Ui::Text::ProgressTracker::UnitTest < Test::Unit::TestCase
  7. def test_stuff
  8. output = Rex::Ui::Text::Output::Buffer.new
  9. pt = Rex::Ui::Text::ProgressTracker.new(output)
  10. pt.range = 1..10
  11. assert_equal(1, pt.start)
  12. assert_equal(10, pt.stop)
  13. pt.start = 2
  14. assert_equal(2, pt.start)
  15. pt.stop = 9
  16. assert_equal(9, pt.stop)
  17. assert_equal(2, pt.pos)
  18. assert_equal('', output.buf)
  19. assert_equal(3, pt.step)
  20. assert_equal(4, pt.step("test"))
  21. assert_equal("[*] 4: test\n", output.buf)
  22. output.reset
  23. assert_equal("[-] bad\n", pt.error("bad"))
  24. output.reset
  25. assert_equal("[-] fatal: bad\n", pt.abort("bad"))
  26. end
  27. end