Permalink
Browse files

Test #each

  • Loading branch information...
1 parent 0b3c820 commit e16746e344080d5442a02244472257237ee955ba @drbrain committed Mar 28, 2011
Showing with 46 additions and 2 deletions.
  1. +46 −2 test/test_pasteboard.rb
View
@@ -62,6 +62,50 @@ def test_copy_item_flavor_data
assert_equal Encoding::UTF_8, data.encoding if @encoding
end
+ def test_each
+ util_put_many
+
+ items = []
+
+ @pb.each do |item|
+ items << item[0, 2]
+ end
+
+ assert_equal [@item1, @item2], items
+ end
+
+ def test_each_enum
+ enum = @pb.each
+
+ enum_klass = defined?(Enumerator) ? Enumerator : Enumerable::Enumerator
+
+ assert_kind_of enum_klass, enum
+ end
+
+ def test_each_flavor
+ util_put_many
+
+ items = []
+
+ @pb.each Pasteboard::Type::UTF_8 do |item|
+ items << item
+ end
+
+ assert_equal ['π', ''], items
+ end
+
+ def test_each_flavor_missing
+ util_put_many
+
+ items = []
+
+ @pb.each Pasteboard::Type::JPEG do |item|
+ items << item
+ end
+
+ assert_equal [nil, nil], items
+ end
+
def test_first
util_put
@@ -200,8 +244,8 @@ def util_put_many
]
@item2 = [
- [Pasteboard::Type::PLAIN_TEXT, ''],
- [Pasteboard::Type::UTF_8, '0 degrees'],
+ [Pasteboard::Type::UTF_8, ''],
+ [Pasteboard::Type::PLAIN_TEXT, '0 degrees'],
]
@pb.put @item1, @item2

0 comments on commit e16746e

Please sign in to comment.