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

Function TestDecimalFormatter

cpp/src/arrow/util/formatting_util_test.cc:313–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

311
312template <typename T>
313void TestDecimalFormatter() {
314 struct TestParam {
315 int64_t test_value;
316 int32_t scale;
317 std::string expected_string;
318 };
319
320 // Borrow from Decimal::ToString test
321 const auto decimalTestData = std::vector<TestParam>{
322 {0, -1, "0E+1"},
323 {0, 0, "0"},
324 {0, 1, "0.0"},
325 {0, 6, "0.000000"},
326 {2, 7, "2E-7"},
327 {2, -1, "2E+1"},
328 {2, 0, "2"},
329 {2, 1, "0.2"},
330 {2, 6, "0.000002"},
331 {-2, 7, "-2E-7"},
332 {-2, 7, "-2E-7"},
333 {-2, -1, "-2E+1"},
334 {-2, 0, "-2"},
335 {-2, 1, "-0.2"},
336 {-2, 6, "-0.000002"},
337 {-2, 7, "-2E-7"},
338 {123, -3, "1.23E+5"},
339 {123, -1, "1.23E+3"},
340 {123, 1, "12.3"},
341 {123, 0, "123"},
342 {123, 5, "0.00123"},
343 {123, 8, "0.00000123"},
344 {123, 9, "1.23E-7"},
345 {123, 10, "1.23E-8"},
346 {-123, -3, "-1.23E+5"},
347 {-123, -1, "-1.23E+3"},
348 {-123, 1, "-12.3"},
349 {-123, 0, "-123"},
350 {-123, 5, "-0.00123"},
351 {-123, 8, "-0.00000123"},
352 {-123, 9, "-1.23E-7"},
353 {-123, 10, "-1.23E-8"},
354 {1000000000, -3, "1.000000000E+12"},
355 {1000000000, -1, "1.000000000E+10"},
356 {1000000000, 0, "1000000000"},
357 {1000000000, 1, "100000000.0"},
358 {1000000000, 5, "10000.00000"},
359 {1000000000, 15, "0.000001000000000"},
360 {1000000000, 16, "1.000000000E-7"},
361 {1000000000, 17, "1.000000000E-8"},
362 {-1000000000, -3, "-1.000000000E+12"},
363 {-1000000000, -1, "-1.000000000E+10"},
364 {-1000000000, 0, "-1000000000"},
365 {-1000000000, 1, "-100000000.0"},
366 {-1000000000, 5, "-10000.00000"},
367 {-1000000000, 15, "-0.000001000000000"},
368 {-1000000000, 16, "-1.000000000E-7"},
369 {-1000000000, 17, "-1.000000000E-8"},
370 {1234567890123456789LL, -3, "1.234567890123456789E+21"},

Callers

nothing calls this directly

Calls 1

AssertFormattingFunction · 0.85

Tested by

no test coverage detected