/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Shared static test methods for numerical tests. Sharing these
* helper test methods avoids repeated functions in the various test
* programs. The test methods return 1 for a test failure and 0 for
* success. The order of arguments to the test methods is generally
* the test name, followed by the test arguments, the computed result,
* and finally the expected result.
*/
public class Tests {
return Float.toHexString(f);
else
}
return Double.toHexString(d);
else
}
return 1;
}
else
return 0;
}
return 1;
}
else
return 0;
}
return 1;
}
return 0;
}
return 1;
}
return 0;
}
return 1;
}
return 0;
}
return 1;
}
else
return 0;
}
return 1;
}
else
return 0;
}
return 1;
}
else
return 0;
}
return 1;
}
else
return 0;
}
return 1;
}
else
return 0;
}
+ input2 + "\n" +
return 1;
}
else
return 0;
}
+ input2 + "\n" +
return 1;
}
else
return 0;
}
// We assume we won't be unlucky and have an inexact expected
// be nextDown(2^i) when 2^i would be the correctly rounded
// answer. This would cause the ulp size to be half as large
// as it should be, doubling the measured error).
return 0; // result and expected are equivalent
} else {
if( ulps == 0.0) {
// Equivalent results required but not found
return 1;
} else {
// fail if greater than or unordered
return 1;
}
else
return 0;
}
}
}
// One input argument.
if (code == 1) {
"\tdifference greater than ulp tolerance " + ulps);
}
return code;
}
// Two input arguments.
if (code == 1) {
"\tdifference greater than ulp tolerance " + ulps);
}
return code;
}
// For a successful test, the result must be within the ulp bound of
// expected AND the result must have absolute value less than or
// equal to absBound.
code = 1;
} else
if (code == 1) {
"\tdifference greater than ulp tolerance " + ulps +
" or the result has larger magnitude than " + absBound);
}
return code;
}
// For a successful test, the result must be within the ulp bound of
// expected AND the result must have absolute value greater than
// or equal to the lowerBound.
double ulps, double lowerBound) {
code = 1;
} else
if (code == 1) {
":\n" +
"\ndifference greater than ulp tolerance " + ulps +
" or result not greater than or equal to the bound " + lowerBound);
}
return code;
}
// fail if greater than or unordered
"\tdifference greater than tolerance 10^-" + tolerance);
return 1;
}
return 0;
}
else
return 0;
}
}