PageRenderTime 41ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/test/lib/regexr.rb.ut.rb

https://bitbucket.org/technopunk2099/metasploit-framework
Ruby | 73 lines | 55 code | 15 blank | 3 comment | 0 complexity | 98b15786f27a51fa3f0c5631043b540e MD5 | raw file
Possible License(s): BSD-3-Clause, Apache-2.0, LGPL-2.1, GPL-2.0, MIT
  1. ##
  2. ## Tests for the regexr library
  3. ## $Id$
  4. $:.unshift(File.expand_path(File.dirname(__FILE__)) )
  5. require 'test/unit'
  6. require 'regexr'
  7. class RegexrTest < Test::Unit::TestCase
  8. def setup
  9. @r = Regexr.new
  10. end
  11. def teardown
  12. @r = nil
  13. end
  14. def test_determine_start
  15. assert @r.verify_start("this is the start\nof a line", "this is the start")
  16. end
  17. def test_determine_end
  18. assert @r.verify_end("this is the start\nof a line", "of a line")
  19. end
  20. def test_determine start_end
  21. assert @r.verify_start_and_end("this is the start\nof a line", "this is the start", "of a line")
  22. end
  23. def test_success_not_defined
  24. assert @r.ensure_all_exist_in_data("i can't get no\nsatisfaction")
  25. end
  26. def test_no_success
  27. assert !@r.ensure_all_exist_in_data("i can't get no\nsatisfaction", ["beast of burden"])
  28. end
  29. def test_single_success
  30. assert @r.ensure_all_exist_in_data("this is the start\nof a line\nbut it's not the end", ["of a line"])
  31. end
  32. def test_multiple_successes
  33. assert @r.ensure_all_exist_in_data("this is the start\nof a line\nbut it's not the end", ["this is the start","of a line"])
  34. end
  35. def test_failure_not_defined
  36. assert @r.ensure_none_exist_in_data("this is the start\nof a line\nbut it's not the end")
  37. end
  38. def test_no_failure
  39. assert @r.ensure_none_exist_in_data("this is the start\nof a line\nbut it's not the end", ["nope, no failure here"])
  40. end
  41. def test_single_failure
  42. assert !@r.ensure_none_exist_in_data("this is the start\nof a line\nbut it's not the end", ["of a line", "there's a failure here somewhere"])
  43. end
  44. def test_multiple_failures
  45. assert !@r.ensure_none_exist_in_data("this is the start\nof a line\nbut it's not the end", ["of a line","but it's not the end"])
  46. end
  47. def test_excepted_failure
  48. assert @r.ensure_none_exist_in_data("this is the start\nof a line\nbut it's not the end", ["no way man", "end"], ["but it's not the end"])
  49. end
  50. def test_success_and_failure
  51. assert @r.ensure_all_exist_in_data("this is the start\nof a line\nbut it's not the end", ["but it's not the end"])
  52. assert !@r.ensure_none_exist_in_data("this is the start\nof a line\nbut it's not the end", ["no way man", "end"])
  53. end
  54. end