KiCad PCB EDA Suite
Loading...
Searching...
No Matches
group_saveload.cpp File Reference
#include <bitset>
#include <filesystem>
#include <string>
#include <board.h>
#include <footprint.h>
#include <pcb_generator.h>
#include <pcb_group.h>
#include <pcb_text.h>
#include <pcb_track.h>
#include <generators/pcb_tuning_pattern.h>
#include <common.h>
#include <pcbnew_utils/board_construction_utils.h>
#include <pcbnew_utils/board_file_utils.h>
#include <qa_utils/wx_utils/unit_test_utils.h>

Go to the source code of this file.

Enumerations

enum  ItemType {
  TEXT0 , TEXT1 , TEXT2 , TEXT3 ,
  TEXT4 , TEXT5 , TEXT6 , TEXT7 ,
  TEXT8 , REMOVED_TEXT , GROUP0 , GROUP1 ,
  GROUP2 , NAME_GROUP3 , NAME_GROUP4 , NAME_GROUP3_DUP ,
  REMOVED_GROUP , NUM_ITEMS
}
 

Functions

std::unique_ptr< BOARDcreateBoard (const std::vector< std::vector< ItemType > > &spec)
 
void testGroupEqual (const PCB_GROUP &group1, const PCB_GROUP &group2)
 
void testGroupsEqual (const GROUPS &groups1, const GROUPS &groups2)
 
void testSaveLoad (const std::vector< std::vector< ItemType > > &spec)
 
 BOOST_AUTO_TEST_CASE (HealthyGroups)
 
 BOOST_AUTO_TEST_CASE (SingleMemberGroupsSaved)
 
 BOOST_AUTO_TEST_CASE (InvalidGroups)
 
 BOOST_AUTO_TEST_CASE (DeepCloneGroupMembership)
 Verify that PCB_GROUP::DeepClone produces a group whose m_items reference the cloned children rather than the originals, and that the cloned group round-trips through save/load with correct membership.
 
 BOOST_AUTO_TEST_CASE (DeepCloneNestedGeneratorMembership)
 Verify that PCB_GENERATOR::DeepClone correctly recurses into nested generators, not just nested groups.
 

Variables

static PCB_TEXTs_removedText = nullptr
 
static PCB_GROUPs_removedGroup = nullptr
 

Enumeration Type Documentation

◆ ItemType

enum ItemType
Enumerator
TEXT0 
TEXT1 
TEXT2 
TEXT3 
TEXT4 
TEXT5 
TEXT6 
TEXT7 
TEXT8 
REMOVED_TEXT 
GROUP0 
GROUP1 
GROUP2 
NAME_GROUP3 
NAME_GROUP4 
NAME_GROUP3_DUP 
REMOVED_GROUP 
NUM_ITEMS 

Definition at line 45 of file group_saveload.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/5]

BOOST_AUTO_TEST_CASE ( DeepCloneGroupMembership )

Verify that PCB_GROUP::DeepClone produces a group whose m_items reference the cloned children rather than the originals, and that the cloned group round-trips through save/load with correct membership.

Definition at line 287 of file group_saveload.cpp.

References APPEND, KIID::AsString(), BOOST_CHECK_EQUAL(), BOOST_CHECK_MESSAGE(), KI_TEST::DumpBoardToFile(), EDA_GROUP::GetItems(), EDA_GROUP::GetName(), group, EDA_ITEM::m_Uuid, path, KI_TEST::ReadBoardFromFileOrStream(), RECURSE, PCB_GROUP::RunOnChildren(), and EDA_TEXT::SetText().

◆ BOOST_AUTO_TEST_CASE() [2/5]

BOOST_AUTO_TEST_CASE ( DeepCloneNestedGeneratorMembership )

Verify that PCB_GENERATOR::DeepClone correctly recurses into nested generators, not just nested groups.

Without this, a generator containing another generator would leave the inner generator's m_items pointing at original board items.

Definition at line 361 of file group_saveload.cpp.

References EDA_GROUP::AddItem(), BOOST_CHECK_EQUAL(), PCB_GENERATOR::DeepClone(), EDA_GROUP::GetItems(), PCB_GENERATOR_T, text, and EDA_ITEM::Type().

◆ BOOST_AUTO_TEST_CASE() [3/5]

BOOST_AUTO_TEST_CASE ( HealthyGroups )

Definition at line 229 of file group_saveload.cpp.

References GROUP0, GROUP1, NAME_GROUP3, testSaveLoad(), TEXT0, TEXT1, TEXT2, TEXT3, TEXT4, TEXT5, and TEXT6.

◆ BOOST_AUTO_TEST_CASE() [4/5]

BOOST_AUTO_TEST_CASE ( InvalidGroups )

◆ BOOST_AUTO_TEST_CASE() [5/5]

BOOST_AUTO_TEST_CASE ( SingleMemberGroupsSaved )

◆ createBoard()

◆ testGroupEqual()

void testGroupEqual ( const PCB_GROUP & group1,
const PCB_GROUP & group2 )

◆ testGroupsEqual()

void testGroupsEqual ( const GROUPS & groups1,
const GROUPS & groups2 )

Definition at line 191 of file group_saveload.cpp.

References BOOST_CHECK_EQUAL(), and testGroupEqual().

Referenced by testSaveLoad().

◆ testSaveLoad()

void testSaveLoad ( const std::vector< std::vector< ItemType > > & spec)

Variable Documentation

◆ s_removedGroup

PCB_GROUP* s_removedGroup = nullptr
static

Definition at line 71 of file group_saveload.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and createBoard().

◆ s_removedText

PCB_TEXT* s_removedText = nullptr
static

Definition at line 70 of file group_saveload.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and createBoard().