reliable-msg 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,48 +0,0 @@
1
- #
2
- # = test-uuid.rb - UUID generator test cases
3
- #
4
- # Author:: Assaf Arkin assaf@labnotes.org
5
- # Documentation:: http://trac.labnotes.org/cgi-bin/trac.cgi/wiki/RubyReliableMessaging
6
- # Copyright:: Copyright (c) 2005 Assaf Arkin
7
- # License:: MIT and/or Creative Commons Attribution-ShareAlike
8
- #
9
- #--
10
- #++
11
-
12
-
13
- require 'test/unit'
14
- require 'uuid'
15
-
16
- class TestUUID < Test::Unit::TestCase
17
-
18
- def setup
19
- end
20
-
21
- def teardown
22
- end
23
-
24
- def test_format
25
- 10.times do
26
- uuid = UUID.new :compact
27
- assert uuid =~ /^[0-9a-fA-F]{32}$/, "UUID does not conform to :compact format"
28
- uuid = UUID.new :default
29
- assert uuid =~ /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/, "UUID does not conform to :default format"
30
- uuid = UUID.new :urn
31
- assert uuid =~ /^urn:uuid:[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/i, "UUID does not conform to :urn format"
32
- end
33
- end
34
-
35
- def test_monotonic
36
- count = 100000
37
- seen = {}
38
- count.times do |i|
39
- uuid = UUID.new
40
- assert !seen.has_key?(uuid), "UUID repeated"
41
- seen[uuid] = true
42
- print '.' if (i % 10000) == 0
43
- STDOUT.flush
44
- end
45
- end
46
-
47
- end
48
-