KiCad PCB EDA Suite
test_sch_sheet_path.cpp File Reference

Test suite for SCH_SHEET_PATH and SCH_SHEET_LIST. More...

#include <qa_utils/wx_utils/unit_test_utils.h>
#include <sch_sheet_path.h>
#include "uuid_test_utils.h"
#include <sch_sheet.h>
#include <sstream>

Go to the source code of this file.

Classes

class  TEST_SCH_SHEET_PATH_FIXTURE
 

Functions

 BOOST_AUTO_TEST_CASE (Empty)
 Declare the test suite. More...
 
 BOOST_AUTO_TEST_CASE (NonEmpty)
 Check properties of a non-empty SCH_SHEET_PATH. More...
 
 BOOST_AUTO_TEST_CASE (Compare)
 
 BOOST_AUTO_TEST_CASE (SheetPathPageProperties)
 Test sheet path page number properties. More...
 

Detailed Description

Test suite for SCH_SHEET_PATH and SCH_SHEET_LIST.

Definition in file test_sch_sheet_path.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/4]

BOOST_AUTO_TEST_CASE ( Compare  )

Definition at line 123 of file test_sch_sheet_path.cpp.

124{
125 SCH_SHEET_PATH otherEmpty;
126
127 BOOST_CHECK( m_empty_path == otherEmpty );
128
129 BOOST_CHECK( m_empty_path != m_linear );
130}
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
BOOST_CHECK(v2.Cross(v1)==1)

References BOOST_CHECK().

◆ BOOST_AUTO_TEST_CASE() [2/4]

BOOST_AUTO_TEST_CASE ( Empty  )

Declare the test suite.

Check properties of an empty SCH_SHEET_PATH

Definition at line 82 of file test_sch_sheet_path.cpp.

83{
84 BOOST_CHECK_EQUAL( m_empty_path.size(), 0 );
85
86 BOOST_CHECK_THROW( m_empty_path.at( 0 ), std::out_of_range );
87
88 // Sheet paths with no SCH_SCHEET object are illegal.
89 // CHECK_WX_ASSERT( m_empty_path.GetPageNumber() );
90
91 // These accessors return nullptr when empty (i.e. they don't crash)
92 BOOST_CHECK_EQUAL( m_empty_path.Last(), nullptr );
93 BOOST_CHECK_EQUAL( m_empty_path.LastScreen(), nullptr );
94
95 BOOST_CHECK_EQUAL( m_empty_path.PathAsString(), "/" );
96 BOOST_CHECK_EQUAL( m_empty_path.PathHumanReadable(), "/" );
97}

◆ BOOST_AUTO_TEST_CASE() [3/4]

BOOST_AUTO_TEST_CASE ( NonEmpty  )

Check properties of a non-empty SCH_SHEET_PATH.

Definition at line 103 of file test_sch_sheet_path.cpp.

104{
105 BOOST_CHECK_EQUAL( m_linear.size(), 3 );
106
107 BOOST_CHECK_EQUAL( m_linear.at( 0 ), &m_sheets[0] );
108 BOOST_CHECK_EQUAL( m_linear.at( 1 ), &m_sheets[1] );
109 BOOST_CHECK_EQUAL( m_linear.at( 2 ), &m_sheets[2] );
110
111 BOOST_CHECK_EQUAL( m_linear.Last(), &m_sheets[2] );
112 BOOST_CHECK_EQUAL( m_linear.LastScreen(), nullptr );
113
114 // don't know what the uuids will be, but we know the format: /<8-4-4-4-12>/<8-4-4-4-12>/
115 BOOST_CHECK_PREDICATE(
116 KI_TEST::IsUUIDPathWithLevels, ( m_linear.PathAsString().ToStdString() )( 2 ) );
117
118 // Sheet0 is the root sheet and isn't in the path
119 BOOST_CHECK_EQUAL( m_linear.PathHumanReadable(), "/Sheet1/Sheet2/" );
120}
bool IsUUIDPathWithLevels(const std::string &aStr, unsigned aLevels)
Predicate to check a string is a UUID path format.

References KI_TEST::IsUUIDPathWithLevels().

◆ BOOST_AUTO_TEST_CASE() [4/4]

BOOST_AUTO_TEST_CASE ( SheetPathPageProperties  )

Test sheet path page number properties.

Definition at line 136 of file test_sch_sheet_path.cpp.

137{
138 // BOOST_CHECK_EQUAL( m_linear.GetPageNumber(), wxEmptyString );
139
140 // Add new instance to sheet object.
141 // BOOST_CHECK( m_linear.Last()->AddInstance( m_linear.Path() ) );
142 // m_linear.SetPageNumber( "1" );
143 // BOOST_CHECK_EQUAL( m_linear.GetPageNumber(), "1" );
144 // m_linear.SetPageNumber( "i" );
145 // BOOST_CHECK_EQUAL( m_linear.GetPageNumber(), "i" );
146}