summaryrefslogtreecommitdiff
path: root/test/-ext-/test_printf.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-25 02:56:36 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-25 02:56:36 +0000
commitbae87a479016504577b7def06f38615837f12b50 (patch)
tree20eed2f9caacc78727f7ef824495b8c42edb59d2 /test/-ext-/test_printf.rb
parent7833e69c2ea4c843f6930b4a80795025f36ab155 (diff)
vsnprintf.c: fix string precision
* vsnprintf.c (BSD_vfprintf): fix string width when precision is given. as the result of `memchr` is NULL or its offset from the start cannot exceed the size, the comparison was always false. [ruby-core:62737] [Bug #9861] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/-ext-/test_printf.rb')
-rw-r--r--test/-ext-/test_printf.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/-ext-/test_printf.rb b/test/-ext-/test_printf.rb
index 609af7c..235865d 100644
--- a/test/-ext-/test_printf.rb
+++ b/test/-ext-/test_printf.rb
@@ -181,4 +181,10 @@ class Test_SPrintf < Test::Unit::TestCase
zero: zr, width: width,
prec: prec))
}
+
+ def test_string_prec
+ assert_equal("a", Bug::Printf.("s", "a", prec: 3)[0])
+ assert_equal(" a", Bug::Printf.("s", "a", width: 3, prec: 3)[0])
+ assert_equal("a ", Bug::Printf.("s", "a", minus: true, width: 3, prec: 3)[0])
+ end
end