File: tc_idgenerator.rb

package info (click to toggle)
ruby-xmpp4r 0.5.6-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 1,384 kB
  • sloc: ruby: 17,382; xml: 74; sh: 12; makefile: 4
file content (30 lines) | stat: -rwxr-xr-x 575 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
#!/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