KiCad PCB EDA Suite
test_format_units.cpp File Reference
#include <qa_utils/wx_utils/unit_test_utils.h>
#include <base_units.h>
#include <locale_io.h>
#include <algorithm>
#include <iostream>

Go to the source code of this file.

Classes

struct  UnitFixture
 

Functions

 BOOST_AUTO_TEST_CASE (wxPointUnitFormat)
 Declares a struct as the Boost test fixture. More...
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE()

BOOST_AUTO_TEST_CASE ( wxPointUnitFormat  )

Declares a struct as the Boost test fixture.

Check formatting the point

Definition at line 46 of file test_format_units.cpp.

47 {
48  LOCALE_IO toggle;
49  std::string str = FormatInternalUnits( wxPoint( 123456, 52525252 ) );
50  std::string strZero = FormatInternalUnits( wxPoint( 0, 0 ) );
51  std::string strNeg = FormatInternalUnits( wxPoint( -123456, -52525252 ) );
52  std::string strOddNeg = FormatInternalUnits( wxPoint( -350000, -0 ) );
53 
54  std::string strMax = FormatInternalUnits( wxPoint( std::numeric_limits<int>::min(),
55  std::numeric_limits<int>::max() ) );
56 
57  BOOST_CHECK_EQUAL( strZero, "0 0" );
58 
59 #ifdef EESCHEMA
60  BOOST_CHECK_EQUAL( str, "12.3456 5252.5252" );
61  BOOST_CHECK_EQUAL( strNeg, "-12.3456 -5252.5252" );
62  BOOST_CHECK_EQUAL( strMax, "-214748.3648 214748.3647" );
63  BOOST_CHECK_EQUAL( strOddNeg, "-35 0" );
64 #elif GERBVIEW
65  BOOST_CHECK_EQUAL( str, "1.23456 525.25252" );
66  BOOST_CHECK_EQUAL( strNeg, "-1.23456 -525.25252" );
67  BOOST_CHECK_EQUAL( strMax, "-21474.83648 21474.83647" );
68  BOOST_CHECK_EQUAL( strOddNeg, "-3.5 0" );
69 #elif PCBNEW
70  BOOST_CHECK_EQUAL( str, "0.123456 52.525252" );
71  BOOST_CHECK_EQUAL( strNeg, "-0.123456 -52.525252" );
72  BOOST_CHECK_EQUAL( strMax, "-2147.483648 2147.483647" );
73  BOOST_CHECK_EQUAL( strOddNeg, "-0.35 0" );
74 #endif
75 
76 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:480

References FormatInternalUnits().