PageRenderTime 42ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/rel-1.3.35/Examples/test-suite/ruby/li_std_deque_runme.rb

#
Ruby | 55 lines | 25 code | 10 blank | 20 comment | 3 complexity | a2af09901428683ae94e60872169a3db MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. #!/usr/bin/env ruby
  2. #
  3. # Put description here
  4. #
  5. #
  6. #
  7. #
  8. #
  9. require 'swig_assert'
  10. require 'li_std_deque'
  11. include Li_std_deque
  12. # Test constructors for std::deque<int>
  13. intDeque = IntDeque.new
  14. intDeque2 = IntDeque.new(3)
  15. intDeque3 = IntDeque.new(4, 42)
  16. intDeque4 = IntDeque.new(intDeque3)
  17. # Test constructors for std::deque<double>
  18. doubleDeque = DoubleDeque.new
  19. doubleDeque2 = DoubleDeque.new(3)
  20. doubleDeque3 = DoubleDeque.new(4, 42.0)
  21. doubleDeque4 = DoubleDeque.new(doubleDeque3)
  22. # Test constructors for std::deque<Real>
  23. realDeque = RealDeque.new
  24. realDeque2 = RealDeque.new(3)
  25. realDeque3 = RealDeque.new(4, 42.0)
  26. realDeque4 = RealDeque.new(realDeque3)
  27. # average() should return the average of all values in a std::deque<int>
  28. intDeque << 2
  29. intDeque << 4
  30. intDeque << 6
  31. avg = average(intDeque)
  32. raise RuntimeError if avg != 4.0
  33. #
  34. # half() should return a std::deque<float>, where each element is half
  35. # the value of the corresponding element in the input deque<float>.
  36. # The original deque's contents are unchanged.
  37. #
  38. realDeque.clear
  39. realDeque << 2.0
  40. halfDeque = half(realDeque)
  41. raise RuntimeError unless halfDeque[0] == 1.0
  42. #
  43. # halve_in_place() should...
  44. #
  45. halve_in_place(doubleDeque)