Sha256: d5414a6dab0a19d6ea14a86ec0c9e0ff7319d33d72ebfe62ced8b70a8a0acfd7

Contents?: true

Size: 805 Bytes

Versions: 6

Compression:

Stored size: 805 Bytes

Contents

# This file is a behavioral specification for the design under test.

# lowest upper bound of counter's value
LIMIT = 2 ** Counter.Size.intVal

# maximum allowed value for a counter
MAX = LIMIT - 1

class ResettedCounterValue < Test::Unit::TestCase
  def setup
    Counter.reset!
  end

  def test_zero
    assert_equal 0, Counter.count.intVal
  end

  def test_increment
    LIMIT.times do |i|
      assert_equal i, Counter.count.intVal
      simulate # increment the counter
    end
  end
end

class MaximumCounterValue < Test::Unit::TestCase
  def setup
    Counter.reset!

    # increment the counter to maximum value
    MAX.times {simulate}
    assert_equal MAX, Counter.count.intVal
  end

  def test_overflow
    simulate # increment the counter
    assert_equal 0, Counter.count.intVal
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ruby-vpi-14.0.0 samp/counter/counter_xunit_spec.rb
ruby-vpi-15.0.0 samp/counter/counter_xunit_spec.rb
ruby-vpi-15.0.1 samp/counter/counter_xunit_spec.rb
ruby-vpi-15.0.2 samp/counter/counter_xunit_spec.rb
ruby-vpi-16.0.1 samp/counter/counter_xunit_spec.rb
ruby-vpi-16.0.0 samp/counter/counter_xunit_spec.rb