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

Function TestDecimal_Floor

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

Source from the content-addressed store, hash-verified

980}
981
982func TestDecimal_Floor(t *testing.T) {
983 assertFloor := func(input, expected Decimal) {
984 got := input.Floor()
985 if !got.Equal(expected) {
986 t.Errorf("Floor(%s): got %s, expected %s", input, got, expected)
987 }
988 }
989 type testDataString struct {
990 input string
991 expected string
992 }
993 testsWithStrings := []testDataString{
994 {"1.999", "1"},
995 {"1", "1"},
996 {"1.01", "1"},
997 {"0", "0"},
998 {"0.9", "0"},
999 {"0.1", "0"},
1000 {"-0.9", "-1"},
1001 {"-0.1", "-1"},
1002 {"-1.00", "-1"},
1003 {"-1.01", "-2"},
1004 {"-1.999", "-2"},
1005 }
1006 for _, test := range testsWithStrings {
1007 expected, _ := NewFromString(test.expected)
1008 input, _ := NewFromString(test.input)
1009 assertFloor(input, expected)
1010 }
1011
1012 type testDataDecimal struct {
1013 input Decimal
1014 expected string
1015 }
1016 testsWithDecimals := []testDataDecimal{
1017 {New(100, -1), "10"},
1018 {New(10, 0), "10"},
1019 {New(1, 1), "10"},
1020 {New(1999, -3), "1"},
1021 {New(101, -2), "1"},
1022 {New(1, 0), "1"},
1023 {New(0, 0), "0"},
1024 {New(9, -1), "0"},
1025 {New(1, -1), "0"},
1026 {New(-1, -1), "-1"},
1027 {New(-9, -1), "-1"},
1028 {New(-1, 0), "-1"},
1029 {New(-101, -2), "-2"},
1030 {New(-1999, -3), "-2"},
1031 }
1032 for _, test := range testsWithDecimals {
1033 expected, _ := NewFromString(test.expected)
1034 assertFloor(test.input, expected)
1035 }
1036}
1037
1038func TestDecimal_Ceil(t *testing.T) {
1039 assertCeil := func(input, expected Decimal) {

Callers

nothing calls this directly

Calls 4

NewFromStringFunction · 0.85
NewFunction · 0.85
FloorMethod · 0.80
EqualMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…