PageRenderTime 48ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/ciarray.rb

https://bitbucket.org/tagoh/prune
Ruby | 78 lines | 47 code | 15 blank | 16 comment | 2 complexity | d2327972bb9eacf1db23f9647cad0d9b MD5 | raw file
Possible License(s): GPL-2.0
  1. # ciarray.rb
  2. # Copyright (C) 2009 Akira TAGOH
  3. # Authors:
  4. # Akira TAGOH <akira@tagoh.org>
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software
  15. # Foundation, Inc., 59 Temple Place - Suite 330,
  16. # Boston, MA 02111-1307, USA.
  17. require 'rubygems'
  18. gem 'test-unit'
  19. require 'test/unit/testcase'
  20. require 'prune/ciarray'
  21. class TestPRUNE__CiArray < Test::Unit::TestCase
  22. def setup
  23. end # def setup
  24. def teardown
  25. end # def teardown
  26. def test_functional
  27. t = PRUNE::CiArray.new
  28. assert_nothing_raised {t[0] = "Foo"}
  29. assert_nothing_raised {t[1] = 1}
  30. assert_nothing_raised {t[2] = :Foo}
  31. end # def test_functional
  32. def test_include
  33. t = PRUNE::CiArray.new
  34. assert_nothing_raised {t[0] = "Foo"}
  35. assert_nothing_raised {t[1] = 1}
  36. assert_nothing_raised {t[2] = :Foo}
  37. assert_equal(true, t.include?("foo"))
  38. assert_equal(true, t.include?("fOO"))
  39. assert_equal(true, t.include?(1))
  40. assert_equal(true, t.include?(:Foo))
  41. assert_equal(false, t.include?("1"))
  42. assert_equal(true, t.include?(:foo))
  43. end # def test_include
  44. def test_delete
  45. t = PRUNE::CiArray.new
  46. assert_nothing_raised {t[0] = "Foo"}
  47. assert_nothing_raised {t[1] = 1}
  48. assert_nothing_raised {t[2] = :Foo}
  49. assert_nothing_raised {t.delete("fOO")}
  50. assert_equal(false, t.include?("foo"))
  51. assert_nothing_raised {t.delete(1)}
  52. assert_equal(false, t.include?(1))
  53. assert_nothing_raised {t.delete(:Foo)}
  54. assert_equal(false, t.include?(:Foo))
  55. end # def test_delete
  56. end # class TestPRUNE__CiArray
  57. if $0 == __FILE__ then
  58. begin
  59. require 'main'
  60. rescue LoadError
  61. require 'tests/main'
  62. end
  63. end