Check the encoding of half:
option
This commit is contained in:
parent
af899503a6
commit
1ddc719a56
@ -233,6 +233,7 @@ rb_num_get_rounding_option(VALUE opts)
|
|||||||
str = rb_check_string_type(rounding);
|
str = rb_check_string_type(rounding);
|
||||||
if (NIL_P(str)) goto invalid;
|
if (NIL_P(str)) goto invalid;
|
||||||
}
|
}
|
||||||
|
rb_must_asciicompat(str);
|
||||||
s = RSTRING_PTR(str);
|
s = RSTRING_PTR(str);
|
||||||
switch (RSTRING_LEN(str)) {
|
switch (RSTRING_LEN(str)) {
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -764,6 +764,9 @@ class TestFloat < Test::Unit::TestCase
|
|||||||
assert_raise_with_message(ArgumentError, /xxx/) {
|
assert_raise_with_message(ArgumentError, /xxx/) {
|
||||||
1.0.round(half: "\0xxx")
|
1.0.round(half: "\0xxx")
|
||||||
}
|
}
|
||||||
|
assert_raise_with_message(Encoding::CompatibilityError, /ASCII incompatible/) {
|
||||||
|
1.0.round(half: "up".force_encoding("utf-16be"))
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_Float
|
def test_Float
|
||||||
|
Loading…
x
Reference in New Issue
Block a user