test/packing_test.rb in packable-1.3.1 vs test/packing_test.rb in packable-1.3.2
- old
+ new
@@ -74,9 +74,27 @@
should "do basic type checking" do
assert_raise(TypeError) {"".unpack(42, :short)}
end
+ context "Reading beyond the eof" do
+ should "raises an EOFError when reading" do
+ ["", "x"].each do |s|
+ io = StringIO.new(s)
+ assert_raise(EOFError) {io.read(:double)}
+ assert_raise(EOFError) {io.read(:short)}
+ assert_raise(EOFError) {io.read(String, :bytes => 4)}
+ end
+ end
+
+ should "return nil for unpacking" do
+ assert_nil "".unpack(:double)
+ assert_nil "".unpack(:short)
+ assert_nil "x".unpack(:double)
+ assert_nil "x".unpack(:short)
+ end
+ end
+
context "Filters" do
context "for Object" do
Object.packers.set :generic_class_writer do |packer|
packer.write do |io|
io << self.class.name << self
\ No newline at end of file