Created
September 24, 2010 00:19
-
-
Save ninjudd/594653 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_get_some_with_validation | |
100.times do |i| | |
i = -i if i.odd? | |
m.set(i.to_s, i) | |
assert_equal i, m.get(i.to_s) | |
end | |
keys = (0...100).collect {|key| key.to_s} | |
results = m.get_some(keys, :validation => lambda {|k,v| k.to_i == v}) do |missing_keys| | |
assert_equal 50, missing_keys.size | |
r = {} | |
missing_keys.each do |key| | |
r[key] = key.to_i | |
end | |
r | |
end | |
assert_equal 100, results.size | |
results.each do |key, value| | |
assert_equal key.to_i, value | |
end | |
results = m.get_some(keys, :validation => lambda {|k,v| k.to_i == v}) do |missing_keys| | |
flunk "no values should be invalid" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment