Package org.djunits.value.formatter
Class EngineeringFormatterTest
java.lang.Object
org.djunits.value.formatter.EngineeringFormatterTest
Test the Engineering formatter
Copyright (c) 2015-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUNITS License.
- Version:
- $Revision: 954 $, $LastChangedDate: 2022-01-10 03:42:57 +0100 (Mon, 10 Jan 2022) $, by $Author: averbraeck $,
initial version 11 sep. 2015
- Author:
- Peter Knoppers
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
See if we can increase the code coverage to include the private constructor.static String
convertAndVerify
(double val, int room) Call convert and then verify that the result is an accurate representation of the value.final void
Test cleverly chosen values plus and minus one ULP.final void
Check that values are formatted at optimal precision when the room is varied.static void
testD
(double d, int width) Print result of main value and value plus or minus one ULP.final void
ulpTest()
Run ulpTest with both values of the parameter.static void
verifyResult
(double value, String text, int room) Check that a double value is represented by a string as accurately as possible; i.e. the last digit in the mantissa is rounded correctly.final void
Run widthTest with both values of the parameter.
-
Constructor Details
-
EngineeringFormatterTest
public EngineeringFormatterTest()
-
-
Method Details
-
constructorTest
@Test public final void constructorTest() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetExceptionSee if we can increase the code coverage to include the private constructor.- Throws:
InstantiationException
- on reflection errorIllegalAccessException
- on reflection errorIllegalArgumentException
- on reflection errorInvocationTargetException
- on reflection error
-
ulpTest
@Test public final void ulpTest()Run ulpTest with both values of the parameter. -
doULPTest
public final void doULPTest()Test cleverly chosen values plus and minus one ULP. -
widthTest
@Test public final void widthTest()Run widthTest with both values of the parameter. -
doWidthTest
public final void doWidthTest()Check that values are formatted at optimal precision when the room is varied. -
testD
public static void testD(double d, int width) Print result of main value and value plus or minus one ULP.- Parameters:
d
- double; the valuewidth
- int; width parameter of the converter
-
convertAndVerify
Call convert and then verify that the result is an accurate representation of the value.- Parameters:
val
- double; value to convertroom
- int; width of the output of convert- Returns:
- String; the converted value
-
verifyResult
Check that a double value is represented by a string as accurately as possible; i.e. the last digit in the mantissa is rounded correctly.- Parameters:
value
- double; the valuetext
- String; the textual representation of valueroom
- int; the expected length of the text
-