Skip to content

Commit 7900c25

Browse files
committed
Add tests with unknown directives for Array#pack, String#unpack
1 parent 8bb046b commit 7900c25

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

core/array/pack/unknown_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require_relative '../../../spec_helper'
2+
3+
describe "Array#pack with unknown directive" do
4+
it "raises ArgumentError" do
5+
-> { [1, 2, 3].pack("ijk") }.should raise_error(ArgumentError, "unknown pack directive 'k' in 'ijk'")
6+
end
7+
end

core/string/unpack_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,8 @@
2929
it "raises an ArgumentError when the offset is larger than the string" do
3030
-> { "a".unpack("C", offset: 2) }.should raise_error(ArgumentError, "offset outside of string")
3131
end
32+
33+
it "raises an ArgumentError if a directive is unknown" do
34+
-> { "a".unpack("ijk") }.should raise_error(ArgumentError, "unknown unpack directive 'k' in 'ijk'")
35+
end
3236
end

0 commit comments

Comments
 (0)