diff options
author | Kenta Murata <mrkn@mrkn.jp> | 2021-10-27 17:31:45 +0900 |
---|---|---|
committer | Kenta Murata <mrkn@mrkn.jp> | 2021-12-24 02:28:54 +0900 |
commit | b2a74948b6fe60727235b80ab56b4c701c315aa3 (patch) | |
tree | ec1d4e73b8bd6278b0529160ee33f0994a992aaf /test/bigdecimal/test_bigdecimal.rb | |
parent | ed7f4c24d73333a716ce7944a465f430a7f7f910 (diff) |
[ruby/bigdecimal] Add tests for the issue GH-192
https://github.com/ruby/bigdecimal/commit/e864828b47
Diffstat (limited to 'test/bigdecimal/test_bigdecimal.rb')
-rw-r--r-- | test/bigdecimal/test_bigdecimal.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb index d7b245b0b8..1e6c59535f 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -1,7 +1,6 @@ # frozen_string_literal: false require_relative "helper" require 'bigdecimal/math' -require 'rbconfig/sizeof' class TestBigDecimal < Test::Unit::TestCase include TestBigDecimalBase @@ -101,6 +100,19 @@ class TestBigDecimal < Test::Unit::TestCase assert_not_same(bd, BigDecimal(bd, 1, exception: false)) end + def test_BigDecimal_issue_192 + # https://github.com/ruby/bigdecimal/issues/192 + # https://github.com/rails/rails/pull/42125 + if BASE_FIG == 9 + int = 1_000_000_000_12345_0000 + big = BigDecimal("0.100000000012345e19") + else # BASE_FIG == 4 + int = 1_0000_12_00 + big = BigDecimal("0.1000012e9") + end + assert_equal(BigDecimal(int), big, "[ruby/bigdecimal#192]") + end + def test_BigDecimal_with_invalid_string [ '', '.', 'e1', 'd1', '.e', '.d', '1.e', '1.d', '.1e', '.1d', |