Changed ObjectID#legal_oid_string to ObjectID#legal?
This commit is contained in:
parent
f82925e4a1
commit
5c2ef0176e
|
@ -64,7 +64,7 @@ module XGen
|
|||
# Given a string representation of an ObjectID, return a new ObjectID
|
||||
# with that value.
|
||||
def self.from_string(str)
|
||||
raise "illegal ObjectID format" unless legal_oid_string(str)
|
||||
raise "illegal ObjectID format" unless legal?(str)
|
||||
data = []
|
||||
BYTE_ORDER.each_with_index { |string_position, data_index|
|
||||
data[data_index] = str[string_position * 2, 2].to_i(16)
|
||||
|
@ -72,7 +72,7 @@ module XGen
|
|||
self.new(data)
|
||||
end
|
||||
|
||||
def self.legal_oid_string(str)
|
||||
def self.legal?(str)
|
||||
len = BYTE_ORDER.length * 2
|
||||
str =~ /([0-9a-f]+)/i
|
||||
match = $1
|
||||
|
|
|
@ -73,14 +73,14 @@ class ObjectIDTest < Test::Unit::TestCase
|
|||
assert_equal @o.to_s, o2.to_s
|
||||
end
|
||||
|
||||
def test_legal_oid_string
|
||||
assert !ObjectID.legal_oid_string(nil)
|
||||
assert !ObjectID.legal_oid_string("fred")
|
||||
assert !ObjectID.legal_oid_string("0000")
|
||||
assert !ObjectID.legal_oid_string('000102030405060708090A0')
|
||||
assert ObjectID.legal_oid_string('000102030405060708090A0B')
|
||||
assert ObjectID.legal_oid_string('abcdefABCDEF123456789012')
|
||||
assert !ObjectID.legal_oid_string('abcdefABCDEF12345678901x')
|
||||
def test_legal
|
||||
assert !ObjectID.legal?(nil)
|
||||
assert !ObjectID.legal?("fred")
|
||||
assert !ObjectID.legal?("0000")
|
||||
assert !ObjectID.legal?('000102030405060708090A0')
|
||||
assert ObjectID.legal?('000102030405060708090A0B')
|
||||
assert ObjectID.legal?('abcdefABCDEF123456789012')
|
||||
assert !ObjectID.legal?('abcdefABCDEF12345678901x')
|
||||
end
|
||||
|
||||
def test_from_string_leading_zeroes
|
||||
|
|
Loading…
Reference in New Issue