Class: IdGeneratorTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/vendor/xmpp4r/test/tc_idgenerator.rb

Instance Method Summary collapse

Instance Method Details

#test_instancesObject



10
11
12
# File 'lib/vendor/xmpp4r/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/vendor/xmpp4r/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