Skip to content

Commit 64b5f9b

Browse files
committed
more cases
1 parent af4df79 commit 64b5f9b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

ydb/library/yql/public/decimal/ut/yql_decimal_ut.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ Y_UNIT_TEST_SUITE(TYqlDecimalTest) {
228228
UNIT_ASSERT(IsError(FromStringEx("E2", 35, 15))); // empty
229229
UNIT_ASSERT(IsError(FromStringEx("E2E4", 35, 15))); // empty
230230
UNIT_ASSERT(IsError(FromStringEx("NANE5", 35, 15))); // nan with exp
231+
UNIT_ASSERT(IsError(FromStringEx("infE5", 35, 15))); // inf with exp
232+
UNIT_ASSERT(IsError(FromStringEx("-infe-5", 35, 15))); // inf with exp
231233
UNIT_ASSERT(IsError(FromStringEx("2.1E0X", 35, 2))); // not fully parsed exp
232234
UNIT_ASSERT(IsError(FromStringEx("2.1E+-1", 35, 2))); // two signs
233235
}

ydb/library/yql/public/decimal/yql_decimal.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,15 @@ TInt128 FromStringEx(const TStringBuf& str, ui8 precision, ui8 scale) {
242242
return Err();
243243
}
244244

245+
if (IsInf(r)) {
246+
auto p = str.data();
247+
if (*p == '+' || *p == '-')
248+
++p;
249+
250+
if (!std::isdigit(*p))
251+
return Err();
252+
}
253+
245254
if (const auto e = exp > 0 ? std::max(0, s - p) : std::min(0, s)) {
246255
if (r && IsNormal(r)) {
247256
if (exp > 0)

0 commit comments

Comments
 (0)