MCPcopy
hub / github.com/shopspring/decimal / TestDecimal_RoundUpAndStringFixed

Function TestDecimal_RoundUpAndStringFixed

decimal_test.go:1355–1444  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1353}
1354
1355func TestDecimal_RoundUpAndStringFixed(t *testing.T) {
1356 type testData struct {
1357 input string
1358 places int32
1359 expected string
1360 expectedFixed string
1361 }
1362 tests := []testData{
1363 {"1.454", 0, "2", ""},
1364 {"1.454", 1, "1.5", ""},
1365 {"1.454", 2, "1.46", ""},
1366 {"1.454", 3, "1.454", ""},
1367 {"1.454", 4, "1.454", "1.4540"},
1368 {"1.454", 5, "1.454", "1.45400"},
1369 {"1.554", 0, "2", ""},
1370 {"1.554", 1, "1.6", ""},
1371 {"1.554", 2, "1.56", ""},
1372 {"0.554", 0, "1", ""},
1373 {"0.454", 0, "1", ""},
1374 {"0.454", 5, "0.454", "0.45400"},
1375 {"0", 0, "0", ""},
1376 {"0", 1, "0", "0.0"},
1377 {"0", 2, "0", "0.00"},
1378 {"0", -1, "0", ""},
1379 {"5", 2, "5", "5.00"},
1380 {"5", 1, "5", "5.0"},
1381 {"5", 0, "5", ""},
1382 {"500", 2, "500", "500.00"},
1383 {"500", -2, "500", ""},
1384 {"545", -1, "550", ""},
1385 {"545", -2, "600", ""},
1386 {"545", -3, "1000", ""},
1387 {"545", -4, "10000", ""},
1388 {"499", -3, "1000", ""},
1389 {"499", -4, "10000", ""},
1390 {"1.1001", 2, "1.11", ""},
1391 {"-1.1001", 2, "-1.11", ""},
1392 {"-1.454", 0, "-2", ""},
1393 {"-1.454", 1, "-1.5", ""},
1394 {"-1.454", 2, "-1.46", ""},
1395 {"-1.454", 3, "-1.454", ""},
1396 {"-1.454", 4, "-1.454", "-1.4540"},
1397 {"-1.454", 5, "-1.454", "-1.45400"},
1398 {"-1.554", 0, "-2", ""},
1399 {"-1.554", 1, "-1.6", ""},
1400 {"-1.554", 2, "-1.56", ""},
1401 {"-0.554", 0, "-1", ""},
1402 {"-0.454", 0, "-1", ""},
1403 {"-0.454", 5, "-0.454", "-0.45400"},
1404 {"-5", 2, "-5", "-5.00"},
1405 {"-5", 1, "-5", "-5.0"},
1406 {"-5", 0, "-5", ""},
1407 {"-500", 2, "-500", "-500.00"},
1408 {"-500", -2, "-500", ""},
1409 {"-545", -1, "-550", ""},
1410 {"-545", -2, "-600", ""},
1411 {"-545", -3, "-1000", ""},
1412 {"-545", -4, "-10000", ""},

Callers

nothing calls this directly

Calls 4

NewFromStringFunction · 0.85
EqualMethod · 0.80
StringFixedMethod · 0.80
RoundUpMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…