File: counter_test.rb

package info (click to toggle)
ruby-metriks 0.9.9.8-3.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 288 kB
  • sloc: ruby: 1,877; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 647 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require 'test_helper'

require 'metriks/counter'

class CounterTest < Test::Unit::TestCase
  include ThreadHelper

  def setup
    @counter = Metriks::Counter.new
  end

  def test_increment
    @counter.increment

    assert_equal 1, @counter.count
  end

  def test_increment_threaded
    thread 10, :n => 100 do
      @counter.increment
    end

    assert_equal 1000, @counter.count
  end

  def test_increment_by_more
    @counter.increment 10

    assert_equal 10, @counter.count
  end
  
  def test_increment_by_more_threaded
    thread 10, :n => 100 do
      @counter.increment 10
    end

    assert_equal 10000, @counter.count
  end
end