@Before public void setUp() { double precision = Math.pow(10.0, -10.0); Equals<Double> equality = new DoubleAbsolute(precision); this._double = new EqualsLastValue<Double>(equality, 1); this._converges = new Double[] {4.0, 3.0, 2.0, 1.0 + Math.pow(10.0, -11.0), 1.0}; this._diverges = new Double[this._converges.length]; this._importantNull = new Double[this._converges.length]; this._same = new Double[this._converges.length]; this._unimportantNull = new Double[this._converges.length]; for (int i = 0; i < this._diverges.length; i++) { this._diverges[i] = this._converges[this._converges.length - 1 - i]; this._same[i] = Math.PI; if (1 < i) this._unimportantNull[i] = 0.0; else this._unimportantNull[i] = null; if (3 == i) this._importantNull[i] = null; else this._importantNull[i] = 2.0; } }
/** Test of getEquals method, of class EqualsLastValue. */ @Test public void testGetEquals() { System.out.println("getEquals"); EqualsLastValue instance = this._double; double precision = Math.pow(10.0, -10.0); Equals<Double> result = instance.getEquals(); if (result instanceof DoubleAbsolute) { DoubleAbsolute da = (DoubleAbsolute) result; double resultPrecision = da.getPrecision(); assertEquals("Wrong value of precision from equality.", precision, resultPrecision, 0.0); } else fail("Wrong kind of equality returned."); }
/** Test of setEquals method, of class EqualsLastValue. */ @Test public void testSetEquals() { System.out.println("setEquals"); double precision = Math.pow(10.0, -8.0); Equals<Double> equality = new DoubleRelative(precision); EqualsLastValue instance = this._double; instance.setEquals(equality); Equals<Double> result = instance.getEquals(); if (result instanceof DoubleRelative) { DoubleRelative dr = (DoubleRelative) result; double resultPrecision = dr.getPrecision(); assertEquals("Wrong value of precision from equality.", precision, resultPrecision, 0.0); } else fail("Wrong kind of equality returned."); }