PageRenderTime 20ms CodeModel.GetById 2ms app.highlight 14ms RepoModel.GetById 2ms app.codeStats 0ms

/trunk/Examples/test-suite/ruby/li_std_deque_runme.rb

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