MCPcopy Create free account
hub / github.com/apache/arrow / TestSuccess

Method TestSuccess

cpp/src/arrow/util/decimal_test.cc:1173–1208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1171 Real Pow10(int exp) { return std::pow(static_cast<Real>(10), static_cast<Real>(exp)); }
1172
1173 void TestSuccess() {
1174 const std::vector<ParamType> params{
1175 // clang-format off
1176 {"0", 0, 0.0f},
1177 {"0", 10, 0.0f},
1178 {"0", -10, 0.0f},
1179 {"1", 0, 1.0f},
1180 {"12345", 0, 12345.f},
1181#ifndef __MINGW32__ // MinGW has precision issues
1182 {"12345", 1, 1234.5f},
1183#endif
1184 {"12345", -3, 12345000.f},
1185 // 2**62
1186 {"4611686018427387904", 0, Pow2(62)},
1187 // 2**63 + 2**62
1188 {"13835058055282163712", 0, Pow2(63) + Pow2(62)},
1189 // 2**64 + 2**62
1190 {"23058430092136939520", 0, Pow2(64) + Pow2(62)},
1191 // 10**38 - 2**103
1192#ifndef __MINGW32__ // MinGW has precision issues
1193 {"99999989858795198174164788026374356992", 0, Pow10(38) - Pow2(103)},
1194#endif
1195 // clang-format on
1196 };
1197 for (const ParamType& param : params) {
1198 if (param.decimal_value.size() < Decimal::kMaxPrecision &&
1199 std::abs(param.scale) < Decimal::kMaxScale) {
1200 CheckDecimalToReal<Decimal, Real>(param.decimal_value, param.scale,
1201 param.expected);
1202 if (param.decimal_value != "0") {
1203 CheckDecimalToReal<Decimal, Real>("-" + param.decimal_value, param.scale,
1204 -param.expected);
1205 }
1206 }
1207 }
1208 }
1209};
1210
1211TYPED_TEST_SUITE(TestDecimalToReal, RealTypes);

Callers 1

TYPED_TESTFunction · 0.45

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected