mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@8b743a3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ecc707e233
commit
3e6337b88b
69 changed files with 742 additions and 141 deletions
|
@ -5,7 +5,6 @@ describe "String#chars" do
|
|||
it_behaves_like :string_chars, :chars
|
||||
|
||||
it "returns an array when no block given" do
|
||||
ary = "hello".send(@method)
|
||||
ary.should == ['h', 'e', 'l', 'l', 'o']
|
||||
"hello".chars.should == ['h', 'e', 'l', 'l', 'o']
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,13 +8,13 @@ with_feature :encoding do
|
|||
it_behaves_like :string_codepoints, :codepoints
|
||||
|
||||
it "returns an Array when no block is given" do
|
||||
"abc".send(@method).should == [?a.ord, ?b.ord, ?c.ord]
|
||||
"abc".codepoints.should == [?a.ord, ?b.ord, ?c.ord]
|
||||
end
|
||||
|
||||
it "raises an ArgumentError when no block is given if self has an invalid encoding" do
|
||||
s = "\xDF".force_encoding(Encoding::UTF_8)
|
||||
s.valid_encoding?.should be_false
|
||||
lambda {s.send(@method)}.should raise_error(ArgumentError)
|
||||
lambda { s.codepoints }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
11
spec/ruby/core/string/each_grapheme_cluster_spec.rb
Normal file
11
spec/ruby/core/string/each_grapheme_cluster_spec.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
require_relative 'shared/chars'
|
||||
require_relative 'shared/grapheme_clusters'
|
||||
require_relative 'shared/each_char_without_block'
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "String#each_grapheme_cluster" do
|
||||
it_behaves_like :string_chars, :each_grapheme_cluster
|
||||
it_behaves_like :string_grapheme_clusters, :each_grapheme_cluster
|
||||
it_behaves_like :string_each_char_without_block, :each_grapheme_cluster
|
||||
end
|
||||
end
|
|
@ -4,7 +4,7 @@ class Object
|
|||
def unpack_format(count=nil, repeat=nil)
|
||||
format = "#{instance_variable_get(:@method)}#{count}"
|
||||
format *= repeat if repeat
|
||||
format
|
||||
format.dup # because it may then become tainted
|
||||
end
|
||||
end
|
||||
|
||||
|
|
15
spec/ruby/core/string/grapheme_clusters_spec.rb
Normal file
15
spec/ruby/core/string/grapheme_clusters_spec.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
require_relative 'shared/chars'
|
||||
require_relative 'shared/grapheme_clusters'
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "String#grapheme_clusters" do
|
||||
it_behaves_like :string_chars, :grapheme_clusters
|
||||
it_behaves_like :string_grapheme_clusters, :grapheme_clusters
|
||||
|
||||
it "returns an array when no block given" do
|
||||
string = "ab\u{1f3f3}\u{fe0f}\u{200d}\u{1f308}\u{1F43E}"
|
||||
string.grapheme_clusters.should == ['a', 'b', "\u{1f3f3}\u{fe0f}\u{200d}\u{1f308}", "\u{1F43E}"]
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -7,7 +7,7 @@ describe "String#lines" do
|
|||
it_behaves_like :string_each_line, :lines
|
||||
|
||||
it "returns an array when no block given" do
|
||||
ary = "hello world".send(@method, ' ')
|
||||
ary = "hello world".lines(' ')
|
||||
ary.should == ["hello ", "world"]
|
||||
end
|
||||
|
||||
|
|
|
@ -19,6 +19,23 @@ describe "String#%" do
|
|||
("%d%% %s" % [10, "of chickens!"]).should == "10% of chickens!"
|
||||
end
|
||||
|
||||
describe "output's encoding" do
|
||||
it "is the same as the format string if passed value is encoding-compatible" do
|
||||
[Encoding::ASCII_8BIT, Encoding::US_ASCII, Encoding::UTF_8, Encoding::SHIFT_JIS].each do |encoding|
|
||||
("hello %s!".encode(encoding) % "world").encoding.should == encoding
|
||||
end
|
||||
end
|
||||
|
||||
it "negotiates a compatible encoding if necessary" do
|
||||
("hello %s" % 195.chr).encoding.should == Encoding::ASCII_8BIT
|
||||
("hello %s".encode("shift_jis") % "wörld").encoding.should == Encoding::UTF_8
|
||||
end
|
||||
|
||||
it "raises if a compatible encoding can't be found" do
|
||||
lambda { "hello %s".encode("utf-8") % "world".encode("UTF-16LE") }.should raise_error(Encoding::CompatibilityError)
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is ""..."2.5" do
|
||||
it "formats single % character at the end as literal %" do
|
||||
("%" % []).should == "%"
|
||||
|
|
16
spec/ruby/core/string/shared/grapheme_clusters.rb
Normal file
16
spec/ruby/core/string/shared/grapheme_clusters.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
require_relative '../../../spec_helper'
|
||||
require_relative '../fixtures/classes'
|
||||
|
||||
describe :string_grapheme_clusters, shared: true do
|
||||
it "passes each grapheme cluster in self to the given block" do
|
||||
a = []
|
||||
# test string: abc[rainbow flag emoji][paw prints]
|
||||
"ab\u{1f3f3}\u{fe0f}\u{200d}\u{1f308}\u{1F43E}".send(@method) { |c| a << c }
|
||||
a.should == ['a', 'b', "\u{1f3f3}\u{fe0f}\u{200d}\u{1f308}", "\u{1F43E}"]
|
||||
end
|
||||
|
||||
it "returns self" do
|
||||
s = StringSpecs::MyString.new "ab\u{1f3f3}\u{fe0f}\u{200d}\u{1f308}\u{1F43E}"
|
||||
s.send(@method) {}.should equal(s)
|
||||
end
|
||||
end
|
|
@ -75,9 +75,9 @@ describe "String#slice! with index" do
|
|||
with_feature :encoding do
|
||||
|
||||
it "returns the character given by the character index" do
|
||||
"hellö there".send(@method, 1).should == "e"
|
||||
"hellö there".send(@method, 4).should == "ö"
|
||||
"hellö there".send(@method, 6).should == "t"
|
||||
"hellö there".slice!(1).should == "e"
|
||||
"hellö there".slice!(4).should == "ö"
|
||||
"hellö there".slice!(6).should == "t"
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -151,15 +151,15 @@ describe "String#slice! with index, length" do
|
|||
with_feature :encoding do
|
||||
|
||||
it "returns the substring given by the character offsets" do
|
||||
"hellö there".send(@method, 1,0).should == ""
|
||||
"hellö there".send(@method, 1,3).should == "ell"
|
||||
"hellö there".send(@method, 1,6).should == "ellö t"
|
||||
"hellö there".send(@method, 1,9).should == "ellö ther"
|
||||
"hellö there".slice!(1,0).should == ""
|
||||
"hellö there".slice!(1,3).should == "ell"
|
||||
"hellö there".slice!(1,6).should == "ellö t"
|
||||
"hellö there".slice!(1,9).should == "ellö ther"
|
||||
end
|
||||
|
||||
it "treats invalid bytes as single bytes" do
|
||||
xE6xCB = [0xE6,0xCB].pack('CC').force_encoding('utf-8')
|
||||
"a#{xE6xCB}b".send(@method, 1, 2).should == xE6xCB
|
||||
"a#{xE6xCB}b".slice!(1, 2).should == xE6xCB
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -239,13 +239,13 @@ describe "String#slice! Range" do
|
|||
with_feature :encoding do
|
||||
|
||||
it "returns the substring given by the character offsets of the range" do
|
||||
"hellö there".send(@method, 1..1).should == "e"
|
||||
"hellö there".send(@method, 1..3).should == "ell"
|
||||
"hellö there".send(@method, 1...3).should == "el"
|
||||
"hellö there".send(@method, -4..-2).should == "her"
|
||||
"hellö there".send(@method, -4...-2).should == "he"
|
||||
"hellö there".send(@method, 5..-1).should == " there"
|
||||
"hellö there".send(@method, 5...-1).should == " ther"
|
||||
"hellö there".slice!(1..1).should == "e"
|
||||
"hellö there".slice!(1..3).should == "ell"
|
||||
"hellö there".slice!(1...3).should == "el"
|
||||
"hellö there".slice!(-4..-2).should == "her"
|
||||
"hellö there".slice!(-4...-2).should == "he"
|
||||
"hellö there".slice!(5..-1).should == " there"
|
||||
"hellö there".slice!(5...-1).should == " ther"
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -307,8 +307,8 @@ describe "String#slice! with Regexp" do
|
|||
|
||||
with_feature :encoding do
|
||||
it "returns the matching portion of self with a multi byte character" do
|
||||
"hëllo there".send(@method, /[ë](.)\1/).should == "ëll"
|
||||
"".send(@method, //).should == ""
|
||||
"hëllo there".slice!(/[ë](.)\1/).should == "ëll"
|
||||
"".slice!(//).should == ""
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -391,13 +391,13 @@ describe "String#slice! with Regexp, index" do
|
|||
|
||||
with_feature :encoding do
|
||||
it "returns the encoding aware capture for the given index" do
|
||||
"hår".send(@method, /(.)(.)(.)/, 0).should == "hår"
|
||||
"hår".send(@method, /(.)(.)(.)/, 1).should == "h"
|
||||
"hår".send(@method, /(.)(.)(.)/, 2).should == "å"
|
||||
"hår".send(@method, /(.)(.)(.)/, 3).should == "r"
|
||||
"hår".send(@method, /(.)(.)(.)/, -1).should == "r"
|
||||
"hår".send(@method, /(.)(.)(.)/, -2).should == "å"
|
||||
"hår".send(@method, /(.)(.)(.)/, -3).should == "h"
|
||||
"hår".slice!(/(.)(.)(.)/, 0).should == "hår"
|
||||
"hår".slice!(/(.)(.)(.)/, 1).should == "h"
|
||||
"hår".slice!(/(.)(.)(.)/, 2).should == "å"
|
||||
"hår".slice!(/(.)(.)(.)/, 3).should == "r"
|
||||
"hår".slice!(/(.)(.)(.)/, -1).should == "r"
|
||||
"hår".slice!(/(.)(.)(.)/, -2).should == "å"
|
||||
"hår".slice!(/(.)(.)(.)/, -3).should == "h"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -402,4 +402,14 @@ describe "String#split with Regexp" do
|
|||
broken_str.force_encoding('utf-8')
|
||||
lambda{ broken_str.split(/\r\n|\r|\n/) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
ruby_version_is "2.6" do
|
||||
it "yields each split substrings if a block is given" do
|
||||
a = []
|
||||
returned_object = "chunky bacon".split(" ") { |str| a << str.capitalize }
|
||||
|
||||
returned_object.should == "chunky bacon"
|
||||
a.should == ["Chunky", "Bacon"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,12 +3,14 @@ require_relative '../../../spec_helper'
|
|||
require_relative '../fixtures/classes'
|
||||
require_relative 'shared/basic'
|
||||
require_relative 'shared/string'
|
||||
require_relative 'shared/taint'
|
||||
|
||||
describe "String#unpack with format 'A'" do
|
||||
it_behaves_like :string_unpack_basic, 'A'
|
||||
it_behaves_like :string_unpack_no_platform, 'A'
|
||||
it_behaves_like :string_unpack_string, 'A'
|
||||
it_behaves_like :string_unpack_Aa, 'A'
|
||||
it_behaves_like :string_unpack_taint, 'A'
|
||||
|
||||
it "removes trailing space and NULL bytes from the decoded string" do
|
||||
[ ["a\x00 b \x00", ["a\x00 b", ""]],
|
||||
|
@ -40,6 +42,7 @@ describe "String#unpack with format 'a'" do
|
|||
it_behaves_like :string_unpack_no_platform, 'a'
|
||||
it_behaves_like :string_unpack_string, 'a'
|
||||
it_behaves_like :string_unpack_Aa, 'a'
|
||||
it_behaves_like :string_unpack_taint, 'a'
|
||||
|
||||
it "does not remove trailing whitespace or NULL bytes from the decoded string" do
|
||||
[ ["a\x00 b \x00", ["a\x00 b \x00"]],
|
||||
|
|
|
@ -2,10 +2,12 @@
|
|||
require_relative '../../../spec_helper'
|
||||
require_relative '../fixtures/classes'
|
||||
require_relative 'shared/basic'
|
||||
require_relative 'shared/taint'
|
||||
|
||||
describe "String#unpack with format 'B'" do
|
||||
it_behaves_like :string_unpack_basic, 'B'
|
||||
it_behaves_like :string_unpack_no_platform, 'B'
|
||||
it_behaves_like :string_unpack_taint, 'B'
|
||||
|
||||
it "decodes one bit from each byte for each format character starting with the most significant bit" do
|
||||
[ ["\x00", "B", ["0"]],
|
||||
|
@ -96,6 +98,7 @@ end
|
|||
describe "String#unpack with format 'b'" do
|
||||
it_behaves_like :string_unpack_basic, 'b'
|
||||
it_behaves_like :string_unpack_no_platform, 'b'
|
||||
it_behaves_like :string_unpack_taint, 'b'
|
||||
|
||||
it "decodes one bit from each byte for each format character starting with the least significant bit" do
|
||||
[ ["\x00", "b", ["0"]],
|
||||
|
|
|
@ -2,10 +2,12 @@
|
|||
require_relative '../../../spec_helper'
|
||||
require_relative '../fixtures/classes'
|
||||
require_relative 'shared/basic'
|
||||
require_relative 'shared/taint'
|
||||
|
||||
describe "String#unpack with format 'H'" do
|
||||
it_behaves_like :string_unpack_basic, 'H'
|
||||
it_behaves_like :string_unpack_no_platform, 'H'
|
||||
it_behaves_like :string_unpack_taint, 'H'
|
||||
|
||||
it "decodes one nibble from each byte for each format character starting with the most significant bit" do
|
||||
[ ["\x8f", "H", ["8"]],
|
||||
|
@ -66,6 +68,7 @@ end
|
|||
describe "String#unpack with format 'h'" do
|
||||
it_behaves_like :string_unpack_basic, 'h'
|
||||
it_behaves_like :string_unpack_no_platform, 'h'
|
||||
it_behaves_like :string_unpack_taint, 'h'
|
||||
|
||||
it "decodes one nibble from each byte for each format character starting with the least significant bit" do
|
||||
[ ["\x8f", "h", ["f"]],
|
||||
|
|
|
@ -2,10 +2,12 @@
|
|||
require_relative '../../../spec_helper'
|
||||
require_relative '../fixtures/classes'
|
||||
require_relative 'shared/basic'
|
||||
require_relative 'shared/taint'
|
||||
|
||||
describe "String#unpack with format 'M'" do
|
||||
it_behaves_like :string_unpack_basic, 'M'
|
||||
it_behaves_like :string_unpack_no_platform, 'M'
|
||||
it_behaves_like :string_unpack_taint, 'M'
|
||||
|
||||
it "decodes an empty string" do
|
||||
"".unpack("M").should == [""]
|
||||
|
@ -100,6 +102,7 @@ end
|
|||
describe "String#unpack with format 'm'" do
|
||||
it_behaves_like :string_unpack_basic, 'm'
|
||||
it_behaves_like :string_unpack_no_platform, 'm'
|
||||
it_behaves_like :string_unpack_taint, 'm'
|
||||
|
||||
it "decodes an empty string" do
|
||||
"".unpack("m").should == [""]
|
||||
|
|
|
@ -1,21 +1,52 @@
|
|||
require_relative '../../../spec_helper'
|
||||
require_relative '../fixtures/classes'
|
||||
require_relative 'shared/basic'
|
||||
require_relative 'shared/taint'
|
||||
|
||||
describe "String#unpack with format 'P'" do
|
||||
it_behaves_like :string_unpack_basic, 'P'
|
||||
it_behaves_like :string_unpack_taint, 'P'
|
||||
|
||||
it "returns a random object after consuming a size-of a machine word bytes" do
|
||||
str = "\0" * 1.size
|
||||
str.unpack("P").should be_kind_of(Object)
|
||||
it "round-trips a string through pack and unpack" do
|
||||
["hello"].pack("P").unpack("P5").should == ["hello"]
|
||||
end
|
||||
|
||||
it "cannot unpack a string except from the same object that created it, or a duplicate of it" do
|
||||
packed = ["hello"].pack("P")
|
||||
packed.unpack("P5").should == ["hello"]
|
||||
packed.dup.unpack("P5").should == ["hello"]
|
||||
lambda { packed.to_sym.to_s.unpack("P5") }.should raise_error(ArgumentError, /no associated pointer/)
|
||||
end
|
||||
|
||||
it "taints the unpacked string" do
|
||||
["hello"].pack("P").unpack("P5").first.tainted?.should be_true
|
||||
end
|
||||
|
||||
it "reads as many characters as specified" do
|
||||
["hello"].pack("P").unpack("P1").should == ["h"]
|
||||
end
|
||||
|
||||
it "reads only as far as a NUL character" do
|
||||
["hello"].pack("P").unpack("P10").should == ["hello"]
|
||||
end
|
||||
end
|
||||
|
||||
describe "String#unpack with format 'p'" do
|
||||
it_behaves_like :string_unpack_basic, 'p'
|
||||
it_behaves_like :string_unpack_taint, 'p'
|
||||
|
||||
it "returns a random object after consuming a size-of a machine word bytes" do
|
||||
str = "\0" * 1.size
|
||||
str.unpack("p").should be_kind_of(Object)
|
||||
it "round-trips a string through pack and unpack" do
|
||||
["hello"].pack("p").unpack("p").should == ["hello"]
|
||||
end
|
||||
|
||||
it "cannot unpack a string except from the same object that created it, or a duplicate of it" do
|
||||
packed = ["hello"].pack("p")
|
||||
packed.unpack("p").should == ["hello"]
|
||||
packed.dup.unpack("p").should == ["hello"]
|
||||
lambda { packed.to_sym.to_s.unpack("p") }.should raise_error(ArgumentError, /no associated pointer/)
|
||||
end
|
||||
|
||||
it "taints the unpacked string" do
|
||||
["hello"].pack("p").unpack("p").first.tainted?.should be_true
|
||||
end
|
||||
end
|
||||
|
|
81
spec/ruby/core/string/unpack/shared/taint.rb
Normal file
81
spec/ruby/core/string/unpack/shared/taint.rb
Normal file
|
@ -0,0 +1,81 @@
|
|||
describe :string_unpack_taint, shared: true do
|
||||
it "does not taint returned arrays if given an untainted format string" do
|
||||
"".unpack(unpack_format(2)).tainted?.should be_false
|
||||
end
|
||||
|
||||
it "does not taint returned arrays if given a tainted format string" do
|
||||
format_string = unpack_format(2).dup
|
||||
format_string.taint
|
||||
"".unpack(format_string).tainted?.should be_false
|
||||
end
|
||||
|
||||
it "does not taint returned strings if given an untainted format string" do
|
||||
"".unpack(unpack_format(2)).any?(&:tainted?).should be_false
|
||||
end
|
||||
|
||||
it "does not taint returned strings if given a tainted format string" do
|
||||
format_string = unpack_format(2).dup
|
||||
format_string.taint
|
||||
"".unpack(format_string).any?(&:tainted?).should be_false
|
||||
end
|
||||
|
||||
it "does not taint returned arrays if given an untainted packed string" do
|
||||
"".unpack(unpack_format(2)).tainted?.should be_false
|
||||
end
|
||||
|
||||
it "does not taint returned arrays if given a tainted packed string" do
|
||||
packed_string = ""
|
||||
packed_string.taint
|
||||
packed_string.unpack(unpack_format(2)).tainted?.should be_false
|
||||
end
|
||||
|
||||
it "does not taint returned strings if given an untainted packed string" do
|
||||
"".unpack(unpack_format(2)).any?(&:tainted?).should be_false
|
||||
end
|
||||
|
||||
it "taints returned strings if given a tainted packed string" do
|
||||
packed_string = ""
|
||||
packed_string.taint
|
||||
packed_string.unpack(unpack_format(2)).all?(&:tainted?).should be_true
|
||||
end
|
||||
|
||||
it "does not untrust returned arrays if given an untrusted format string" do
|
||||
"".unpack(unpack_format(2)).untrusted?.should be_false
|
||||
end
|
||||
|
||||
it "does not untrust returned arrays if given a untrusted format string" do
|
||||
format_string = unpack_format(2).dup
|
||||
format_string.untrust
|
||||
"".unpack(format_string).untrusted?.should be_false
|
||||
end
|
||||
|
||||
it "does not untrust returned strings if given an untainted format string" do
|
||||
"".unpack(unpack_format(2)).any?(&:untrusted?).should be_false
|
||||
end
|
||||
|
||||
it "does not untrust returned strings if given a untrusted format string" do
|
||||
format_string = unpack_format(2).dup
|
||||
format_string.untrust
|
||||
"".unpack(format_string).any?(&:untrusted?).should be_false
|
||||
end
|
||||
|
||||
it "does not untrust returned arrays if given an trusted packed string" do
|
||||
"".unpack(unpack_format(2)).untrusted?.should be_false
|
||||
end
|
||||
|
||||
it "does not untrust returned arrays if given a untrusted packed string" do
|
||||
packed_string = ""
|
||||
packed_string.untrust
|
||||
packed_string.unpack(unpack_format(2)).untrusted?.should be_false
|
||||
end
|
||||
|
||||
it "does not untrust returned strings if given an trusted packed string" do
|
||||
"".unpack(unpack_format(2)).any?(&:untrusted?).should be_false
|
||||
end
|
||||
|
||||
it "untrusts returned strings if given a untrusted packed string" do
|
||||
packed_string = ""
|
||||
packed_string.untrust
|
||||
packed_string.unpack(unpack_format(2)).all?(&:untrusted?).should be_true
|
||||
end
|
||||
end
|
|
@ -3,11 +3,13 @@ require_relative '../../../spec_helper'
|
|||
require_relative '../fixtures/classes'
|
||||
require_relative 'shared/basic'
|
||||
require_relative 'shared/unicode'
|
||||
require_relative 'shared/taint'
|
||||
|
||||
describe "String#unpack with format 'U'" do
|
||||
it_behaves_like :string_unpack_basic, 'U'
|
||||
it_behaves_like :string_unpack_no_platform, 'U'
|
||||
it_behaves_like :string_unpack_unicode, 'U'
|
||||
it_behaves_like :string_unpack_taint, 'U'
|
||||
|
||||
it "raises ArgumentError on a malformed byte sequence" do
|
||||
lambda { "\xE3".unpack('U') }.should raise_error(ArgumentError)
|
||||
|
@ -21,6 +23,7 @@ end
|
|||
describe "String#unpack with format 'u'" do
|
||||
it_behaves_like :string_unpack_basic, 'u'
|
||||
it_behaves_like :string_unpack_no_platform, 'u'
|
||||
it_behaves_like :string_unpack_taint, 'u'
|
||||
|
||||
it "decodes an empty string as an empty string" do
|
||||
"".unpack("u").should == [""]
|
||||
|
|
|
@ -3,11 +3,13 @@ require_relative '../../../spec_helper'
|
|||
require_relative '../fixtures/classes'
|
||||
require_relative 'shared/basic'
|
||||
require_relative 'shared/string'
|
||||
require_relative 'shared/taint'
|
||||
|
||||
describe "String#unpack with format 'Z'" do
|
||||
it_behaves_like :string_unpack_basic, 'Z'
|
||||
it_behaves_like :string_unpack_no_platform, 'Z'
|
||||
it_behaves_like :string_unpack_string, 'Z'
|
||||
it_behaves_like :string_unpack_taint, 'Z'
|
||||
|
||||
it "stops decoding at NULL bytes when passed the '*' modifier" do
|
||||
"a\x00\x00 b \x00c".unpack('Z*Z*Z*Z*').should == ["a", "", " b ", "c"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue