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
|
#!/usr/bin/ruby
$:.unshift '../lib'
require 'test/unit'
require 'xmpp4r/idgenerator'
include Jabber
class IdGeneratorTest < Test::Unit::TestCase
def test_instances
assert_equal(Jabber::IdGenerator.instance, Jabber::IdGenerator.instance)
end
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
end
|