Class: IdGeneratorTest

Inherits:
Test::Unit::TestCase show all
Defined in:
lib/gems/xmpp4r-0.4/test/tc_idgenerator.rb

Instance Method Summary collapse

Methods inherited from Test::Unit::TestCase

#assert_array_equal, expect, #run

Instance Method Details

#test_instancesObject



10
11
12
# File 'lib/gems/xmpp4r-0.4/test/tc_idgenerator.rb', line 10

def test_instances
  assert_equal(Jabber::IdGenerator.instance, Jabber::IdGenerator.instance)
end

#test_uniqueObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gems/xmpp4r-0.4/test/tc_idgenerator.rb', line 14

def test_unique
  ids = []
  100.times { ids.push(Jabber::IdGenerator.generate_id) }

  ok = true
  ids.each_index { |a|
    ids.each_index { |b|
      if a == b
        ok = false if ids[a] != ids[b]
      else
        ok = false if ids[a] == ids[b]
      end
    }
  }
  assert(ok)
end