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

Function TestDecimal_RoundCeilAndStringFixed

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

Source from the content-addressed store, hash-verified

1171}
1172
1173func TestDecimal_RoundCeilAndStringFixed(t *testing.T) {
1174 type testData struct {
1175 input string
1176 places int32
1177 expected string
1178 expectedFixed string
1179 }
1180 tests := []testData{
1181 {"1.454", 0, "2", ""},
1182 {"1.454", 1, "1.5", ""},
1183 {"1.454", 2, "1.46", ""},
1184 {"1.454", 3, "1.454", ""},
1185 {"1.454", 4, "1.454", "1.4540"},
1186 {"1.454", 5, "1.454", "1.45400"},
1187 {"1.554", 0, "2", ""},
1188 {"1.554", 1, "1.6", ""},
1189 {"1.554", 2, "1.56", ""},
1190 {"0.554", 0, "1", ""},
1191 {"0.454", 0, "1", ""},
1192 {"0.454", 5, "0.454", "0.45400"},
1193 {"0", 0, "0", ""},
1194 {"0", 1, "0", "0.0"},
1195 {"0", 2, "0", "0.00"},
1196 {"0", -1, "0", ""},
1197 {"5", 2, "5", "5.00"},
1198 {"5", 1, "5", "5.0"},
1199 {"5", 0, "5", ""},
1200 {"500", 2, "500", "500.00"},
1201 {"500", -2, "500", ""},
1202 {"545", -1, "550", ""},
1203 {"545", -2, "600", ""},
1204 {"545", -3, "1000", ""},
1205 {"545", -4, "10000", ""},
1206 {"499", -3, "1000", ""},
1207 {"499", -4, "10000", ""},
1208 {"1.1001", 2, "1.11", ""},
1209 {"-1.1001", 2, "-1.10", ""},
1210 {"-1.454", 0, "-1", ""},
1211 {"-1.454", 1, "-1.4", ""},
1212 {"-1.454", 2, "-1.45", ""},
1213 {"-1.454", 3, "-1.454", ""},
1214 {"-1.454", 4, "-1.454", "-1.4540"},
1215 {"-1.454", 5, "-1.454", "-1.45400"},
1216 {"-1.554", 0, "-1", ""},
1217 {"-1.554", 1, "-1.5", ""},
1218 {"-1.554", 2, "-1.55", ""},
1219 {"-0.554", 0, "0", ""},
1220 {"-0.454", 0, "0", ""},
1221 {"-0.454", 5, "-0.454", "-0.45400"},
1222 {"-5", 2, "-5", "-5.00"},
1223 {"-5", 1, "-5", "-5.0"},
1224 {"-5", 0, "-5", ""},
1225 {"-500", 2, "-500", "-500.00"},
1226 {"-500", -2, "-500", ""},
1227 {"-545", -1, "-540", ""},
1228 {"-545", -2, "-500", ""},
1229 {"-545", -3, "0", ""},
1230 {"-545", -4, "0", ""},

Callers

nothing calls this directly

Calls 4

NewFromStringFunction · 0.85
RoundCeilMethod · 0.80
EqualMethod · 0.80
StringFixedMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…