diff options
author | Benoit Daloze <eregontp@gmail.com> | 2020-05-31 18:22:49 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2020-05-31 18:22:49 +0200 |
commit | 34776105c8a6739ca3aad1de4a2c942f4a8f2f29 (patch) | |
tree | 0103cf2cc89c1322d8c3e88fff0a80b54db8320b /spec/ruby/optional/capi/util_spec.rb | |
parent | f4502b001a665109bf776f9037ecbc52cb5f2d88 (diff) |
Update to ruby/spec@4e486fa
Diffstat (limited to 'spec/ruby/optional/capi/util_spec.rb')
-rw-r--r-- | spec/ruby/optional/capi/util_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/ruby/optional/capi/util_spec.rb b/spec/ruby/optional/capi/util_spec.rb index cf19c55b57..099222b2d0 100644 --- a/spec/ruby/optional/capi/util_spec.rb +++ b/spec/ruby/optional/capi/util_spec.rb @@ -293,4 +293,34 @@ describe "C-API Util function" do end end + # ruby/util.h redefines strtod as a macro calling ruby_strtod + + describe "strtod" do + it "converts a string to a double and returns the remaining string" do + d, s = @o.strtod("14.25test") + d.should == 14.25 + s.should == "test" + end + + it "returns 0 and the full string if there's no numerical value" do + d, s = @o.strtod("test") + d.should == 0 + s.should == "test" + end + end + + describe "ruby_strtod" do + it "converts a string to a double and returns the remaining string" do + d, s = @o.ruby_strtod("14.25test") + d.should == 14.25 + s.should == "test" + end + + it "returns 0 and the full string if there's no numerical value" do + d, s = @o.ruby_strtod("test") + d.should == 0 + s.should == "test" + end + end + end |