KiCad PCB EDA Suite
test_refdes_utils.cpp File Reference

Test suite for refdes functions. More...

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (GetPrefix)
 Declare the test suite. More...
 

Detailed Description

Test suite for refdes functions.

Definition in file test_refdes_utils.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE()

BOOST_AUTO_TEST_CASE ( GetPrefix  )

Declare the test suite.

Test the UTIL::GetRefDesPrefix function

Definition at line 43 of file test_refdes_utils.cpp.

44 {
45  using CASE = std::pair<std::string, std::string>;
46 
47  const std::vector<CASE> cases = {
48  { "", "" }, // empty
49  { "U", "U" }, // no number
50  { "1", "" }, // only number
51  { "IC", "IC" }, // >1 char prefix, no number
52  { "U1", "U" }, // single digit
53  { "IC21", "IC" }, // >1 char prefix + number
54  { "U10", "U" }, // double digit
55  { "U1000", "U" }, // multi digit
56  { "U1U2", "U1U" }, // prefix contains digit
57  };
58 
59  for( const auto& c : cases )
60  {
61  BOOST_TEST_CONTEXT( "Testing: " << c.first )
62  {
63  BOOST_CHECK_EQUAL( UTIL::GetRefDesPrefix( c.first ), c.second );
64  }
65  }
66 }
#define BOOST_TEST_CONTEXT(A)
wxString GetRefDesPrefix(const wxString &aRefDes)
Get the (non-numeric) prefix from a refdes - e.g.

References BOOST_TEST_CONTEXT, and UTIL::GetRefDesPrefix().