Sha256: 652994a70949e19d9ff4f865424746d1194d6fb066329cbbec8ceac81fa682f6
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
# # = test-uuid.rb - UUID generator test cases # # Author:: Assaf Arkin assaf@labnotes.org # Documentation:: http://trac.labnotes.org/cgi-bin/trac.cgi/wiki/Ruby/UuidGenerator # Copyright:: Copyright (c) 2005 Assaf Arkin # License:: MIT and/or Creative Commons Attribution-ShareAlike # #-- #++ require 'test/unit' require 'uuid' class TestUUID < Test::Unit::TestCase def setup end def teardown end def test_format 10.times do uuid = UUID.new :compact assert uuid =~ /^[0-9a-fA-F]{32}$/, "UUID does not conform to :compact format" uuid = UUID.new :default 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" uuid = UUID.new :urn 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" end end def test_monotonic count = 100000 seen = {} count.times do |i| uuid = UUID.new assert !seen.has_key?(uuid), "UUID repeated" seen[uuid] = true print '.' if (i % 10000) == 0 STDOUT.flush end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
uuid-1.0.0 | test/test-uuid.rb |