KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_issue24403_directive_label_i18n.cpp File Reference

Regression coverage for https://gitlab.com/kicad/code/kicad/-/issues/24403. More...

#include <boost/test/unit_test.hpp>
#include <qa_utils/wx_utils/unit_test_utils.h>
#include <eeschema_test_utils.h>
#include <wx/ffile.h>
#include <wx/filename.h>
#include <wx/stdpaths.h>
#include <sch_field.h>
#include <sch_io/kicad_sexpr/sch_io_kicad_sexpr.h>
#include <sch_label.h>
#include <sch_screen.h>
#include <sch_sheet.h>
#include <schematic.h>
#include <settings/settings_manager.h>

Go to the source code of this file.

Classes

struct  DIRECTIVE_LABEL_I18N_FIXTURE
 

Functions

 BOOST_AUTO_TEST_CASE (CanonicalNetclassEmittedForTranslatedFieldName)
 The serializer must always emit the canonical "Netclass" token for the directive-label net class field, even when the in-memory field name happens to be a translated string (which can happen with files written by older KiCad versions).
 
 BOOST_AUTO_TEST_CASE (TranslatedFieldNameRoundTripsAsCanonical)
 Round-trip: a file written by a non-English UI (here we simulate German "Netzklasse") must be recognised as a directive net class binding when reloaded, so that GetCanonicalName() returns the canonical token used by the rest of the code base.
 
 BOOST_AUTO_TEST_CASE (IsNetclassLabelFieldNameRecognisesTranslations)
 Direct contract test for the helper that recognises translated forms.
 

Detailed Description

Regression coverage for https://gitlab.com/kicad/code/kicad/-/issues/24403.

A KiCad UI in German (or any non-English language) used to write the directive-label net class field name as the translated form (e.g. "Netzklasse" in German). When the same file was opened with an English UI the canonical token "Netclass" was no longer present, so the directive label lost its association with the project's net class settings. Cross-language collaboration over Git therefore destroyed all directive-label net class bindings.

These tests pin the contract on both the writer and the migration paths.

Definition in file test_issue24403_directive_label_i18n.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/3]

BOOST_AUTO_TEST_CASE ( CanonicalNetclassEmittedForTranslatedFieldName )

The serializer must always emit the canonical "Netclass" token for the directive-label net class field, even when the in-memory field name happens to be a translated string (which can happen with files written by older KiCad versions).

Definition at line 122 of file test_issue24403_directive_label_i18n.cpp.

References BOOST_AUTO_TEST_CASE(), BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), and SCH_IO_KICAD_SEXPR::SaveSchematicFile().

◆ BOOST_AUTO_TEST_CASE() [2/3]

BOOST_AUTO_TEST_CASE ( IsNetclassLabelFieldNameRecognisesTranslations )

Direct contract test for the helper that recognises translated forms.

Bug fixes that inadvertently shrink the recognised translations will fail this test instead of silently regressing the migration path.

Definition at line 244 of file test_issue24403_directive_label_i18n.cpp.

References SCH_FIELD::IsNetclassLabelFieldName().

◆ BOOST_AUTO_TEST_CASE() [3/3]

BOOST_AUTO_TEST_CASE ( TranslatedFieldNameRoundTripsAsCanonical )

Round-trip: a file written by a non-English UI (here we simulate German "Netzklasse") must be recognised as a directive net class binding when reloaded, so that GetCanonicalName() returns the canonical token used by the rest of the code base.

Definition at line 154 of file test_issue24403_directive_label_i18n.cpp.

References BOOST_CHECK_EQUAL(), BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), SCH_LABEL_BASE::GetFields(), SCH_SHEET::GetScreen(), SCH_SCREEN::Items(), SCH_IO_KICAD_SEXPR::LoadSchematicFile(), EE_RTREE::OfType(), SCH_IO_KICAD_SEXPR::SaveSchematicFile(), and SCH_DIRECTIVE_LABEL_T.