Class: TestHitSq

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/tests.rb

Instance Method Summary collapse

Instance Method Details

#setupObject



32
33
34
35
# File 'lib/tests.rb', line 32

def setup
  @h=[0.2,0.3,0.4].HitSq
  @h2=[0,1].HitSq
end

#test_boundsObject



40
41
42
43
44
# File 'lib/tests.rb', line 40

def test_bounds
  assert_raise(RuntimeError) {[1.1].HitSq}
  assert_raise(RuntimeError) {[-0.1].HitSq}
  assert_raise(RuntimeError) {@h2<<8}
end

#test_hits_moveObject



63
64
65
66
67
# File 'lib/tests.rb', line 63

def test_hits_move
  assert_equal(([0.2,0.3,0.4]), @h.hits)
  @h.move(0.1)
  assert_equal(([0.3,0.4,0.5]), @h.hits)
end

#test_loadedObject



36
37
38
39
# File 'lib/tests.rb', line 36

def test_loaded
  assert_equal(3, @h.count)
  assert_equal(true, @h2.hits.eql?([0.0,1.0]))
end

#test_opsObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/tests.rb', line 46

def test_ops
  @h<<1
  assert_equal(4, @h.count)
  @h<<@h2
  assert_equal(5, @h.count)
  # without the duplicate now
  @h>>1
  assert_equal(4, @h.count)
  
  #
  assert_equal(2, @h2.count)
  @h2>>1.0
  assert_equal(1, @h2.count)
  # Not chaged
  assert_equal(4, @h.count)
end