Class EngineeringFormatterTest

java.lang.Object
org.djunits.value.formatter.EngineeringFormatterTest

public class EngineeringFormatterTest
extends Object
Test the Engineering formatter

Copyright (c) 2015-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUNITS License.

Version:
$Revision: 669 $, $LastChangedDate: 2019-10-18 14:27:35 +0200 (Fri, 18 Oct 2019) $, by $Author: averbraeck $, initial version 11 sep. 2015
Author:
Peter Knoppers
  • Constructor Summary

    Constructors 
    Constructor Description
    EngineeringFormatterTest()  
  • Method Summary

    Modifier and Type Method Description
    void constructorTest()
    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.
    void doULPTest()
    Test cleverly chosen values plus and minus one ULP.
    void doWidthTest()
    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.
    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.
    void widthTest()
    Run widthTest with both values of the parameter.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • constructorTest

      See if we can increase the code coverage to include the private constructor.
      Throws:
      InstantiationException - on reflection error
      IllegalAccessException - on reflection error
      IllegalArgumentException - on reflection error
      InvocationTargetException - on reflection error
    • ulpTest

      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

      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 value
      width - int; width parameter of the converter
    • convertAndVerify

      public static String convertAndVerify​(double val, int room)
      Call convert and then verify that the result is an accurate representation of the value.
      Parameters:
      val - double; value to convert
      room - int; width of the output of convert
      Returns:
      String; the converted value
    • verifyResult

      public 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.
      Parameters:
      value - double; the value
      text - String; the textual representation of value
      room - int; the expected length of the text