From b64661f302ce013d8b3f8fd69815533efb2c33fe Mon Sep 17 00:00:00 2001 From: Andrew Nordman Date: Mon, 9 Oct 2017 22:18:37 +0000 Subject: [PATCH 1/2] Adds String#unpack1 String#unpack1 is pretty straightforward. Return the first matching value of String#unpack. --- core/string/unpack/1_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 core/string/unpack/1_spec.rb diff --git a/core/string/unpack/1_spec.rb b/core/string/unpack/1_spec.rb new file mode 100644 index 0000000000..64077978f6 --- /dev/null +++ b/core/string/unpack/1_spec.rb @@ -0,0 +1,12 @@ +require File.expand_path('../../../../spec_helper', __FILE__) + +ruby_version_is "2.4" do + describe "String#unpack1" do + it "returns the first value of #unpack" do + "ABCD".unpack1('x3C').should == "ABCD".unpack('x3C')[0] + "\u{3042 3044 3046}".unpack1("U*").should == 0x3042 + "aG9nZWZ1Z2E=".unpack1("m").should == "hogefuga" + "A".unpack1("B*").should == "01000001" + end + end +end From f81da1c5dbc6d4eebf24759960fd27df97c88297 Mon Sep 17 00:00:00 2001 From: Andrew Nordman Date: Tue, 10 Oct 2017 14:11:40 +0000 Subject: [PATCH 2/2] Moves unpack1 spec out of modifier folder --- core/string/{unpack/1_spec.rb => unpack1_spec.rb} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename core/string/{unpack/1_spec.rb => unpack1_spec.rb} (84%) diff --git a/core/string/unpack/1_spec.rb b/core/string/unpack1_spec.rb similarity index 84% rename from core/string/unpack/1_spec.rb rename to core/string/unpack1_spec.rb index 64077978f6..6941bc1173 100644 --- a/core/string/unpack/1_spec.rb +++ b/core/string/unpack1_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require File.expand_path('../../../spec_helper', __FILE__) ruby_version_is "2.4" do describe "String#unpack1" do