@@ -80,7 +80,22 @@ public void inf() {
8080 DecimalValue value = type .newValue (inf );
8181 Assert .assertTrue (value .isInf ());
8282 Assert .assertFalse (value .isNegative ());
83- Assert .assertSame (DecimalValue .INF , value );
83+ Assert .assertEquals (DecimalValue .INF , value );
84+ inf = inf .add (k );
85+ }
86+ }
87+
88+ @ Test
89+ public void infDefaulttype () {
90+ DecimalType type = DecimalType .getDefault ();
91+ BigInteger inf = BigInteger .TEN .pow (DecimalType .MAX_PRECISION );
92+ BigInteger k = BigInteger .valueOf (0x10000000_00000000L );
93+
94+ for (int i = 0 ; i < 100 ; i ++) {
95+ DecimalValue value = type .newValue (inf );
96+ Assert .assertTrue (value .isInf ());
97+ Assert .assertFalse (value .isNegative ());
98+ Assert .assertNotEquals (DecimalValue .INF , value );
8499 inf = inf .add (k );
85100 }
86101 }
@@ -95,7 +110,22 @@ public void negativeInf() {
95110 DecimalValue value = type .newValue (inf );
96111 Assert .assertTrue (value .isNegativeInf ());
97112 Assert .assertTrue (value .isNegative ());
98- Assert .assertSame (DecimalValue .NEG_INF , value );
113+ Assert .assertEquals (DecimalValue .NEG_INF , value );
114+ inf = inf .subtract (k );
115+ }
116+ }
117+
118+ @ Test
119+ public void negativeInfDefaultType () {
120+ DecimalType type = DecimalType .getDefault ();
121+ BigInteger inf = BigInteger .TEN .negate ().pow (DecimalType .MAX_PRECISION );
122+ BigInteger k = BigInteger .valueOf (0x10000000_00000000L );
123+
124+ for (int i = 0 ; i < 100 ; i ++) {
125+ DecimalValue value = type .newValue (inf );
126+ Assert .assertTrue (value .isNegativeInf ());
127+ Assert .assertTrue (value .isNegative ());
128+ Assert .assertNotEquals (DecimalValue .NEG_INF , value );
99129 inf = inf .subtract (k );
100130 }
101131 }
@@ -126,19 +156,19 @@ public void zero() {
126156 public void ofString () {
127157 DecimalType t = DecimalType .getDefault ();
128158
129- Assert .assertSame ( DecimalValue . INF , t .newValue ("inf" ));
130- Assert .assertSame ( DecimalValue . INF , t .newValue ("Inf" ));
131- Assert .assertSame ( DecimalValue . INF , t .newValue ("INF" ));
132- Assert .assertSame ( DecimalValue . INF , t .newValue ("+inf" ));
133- Assert .assertSame ( DecimalValue . INF , t .newValue ("+Inf" ));
134- Assert .assertSame ( DecimalValue . INF , t .newValue ("+INF" ));
135- Assert .assertSame ( DecimalValue . NEG_INF , t .newValue ("-inf" ));
136- Assert .assertSame ( DecimalValue . NEG_INF , t .newValue ("-Inf" ));
137- Assert .assertSame ( DecimalValue . NEG_INF , t .newValue ("-INF" ));
138- Assert .assertSame ( DecimalValue . NAN , t .newValue ("nan" ));
139- Assert .assertSame ( DecimalValue . NAN , t .newValue ("Nan" ));
140- Assert .assertSame ( DecimalValue . NAN , t .newValue ("NaN" ));
141- Assert .assertSame ( DecimalValue . NAN , t .newValue ("NAN" ));
159+ Assert .assertTrue ( t .newValue ("inf" ). isInf ( ));
160+ Assert .assertTrue ( t .newValue ("Inf" ). isInf ( ));
161+ Assert .assertTrue ( t .newValue ("INF" ). isInf ( ));
162+ Assert .assertTrue ( t .newValue ("+inf" ). isInf ( ));
163+ Assert .assertTrue ( t .newValue ("+Inf" ). isInf ( ));
164+ Assert .assertTrue ( t .newValue ("+INF" ). isInf ( ));
165+ Assert .assertTrue ( t .newValue ("-inf" ). isNegativeInf ( ));
166+ Assert .assertTrue ( t .newValue ("-Inf" ). isNegativeInf ( ));
167+ Assert .assertTrue ( t .newValue ("-INF" ). isNegativeInf ( ));
168+ Assert .assertTrue ( t .newValue ("nan" ). isNan ( ));
169+ Assert .assertTrue ( t .newValue ("Nan" ). isNan ( ));
170+ Assert .assertTrue ( t .newValue ("NaN" ). isNan ( ));
171+ Assert .assertTrue ( t .newValue ("NAN" ). isNan ( ));
142172
143173 Assert .assertTrue (t .newValue ("0" ).isZero ());
144174 Assert .assertTrue (t .newValue ("00" ).isZero ());
0 commit comments