24#include <initializer_list>
31#include <wx/imagpng.h>
32#include <wx/mstream.h>
34#include <boost/test/unit_test.hpp>
47 throw std::runtime_error(
"Required downgrade test target is missing: " + aId.ToStdString() );
66 std::initializer_list<EXPECTED_DOWNGRADE_FEATURE> aFeatures,
67 bool aDropInsteadOfApproximate )
71 size_t expectedRows = 0;
77 const auto entry = std::find_if( aReport.
Entries().begin(), aReport.
Entries().end(),
80 return aEntry.m_feature == feature.m_name;
83 if( aTargetVersion >= feature.m_introducedIn )
85 BOOST_CHECK( entry == aReport.
Entries().end() );
90 BOOST_REQUIRE_MESSAGE( entry != aReport.
Entries().end(),
"Transform fixture no longer exercises feature" );
91 BOOST_CHECK_GT( entry->m_count, 0 );
94 && !feature.m_keepUnderOmitPolicy
97 BOOST_CHECK( entry->m_bucket == expectedBucket );
109 if( !wxImage::FindHandler( wxBITMAP_TYPE_PNG ) )
110 wxImage::AddHandler(
new wxPNGHandler );
113 img.SetOption( wxIMAGE_OPTION_RESOLUTIONX, 96 );
114 img.SetOption( wxIMAGE_OPTION_RESOLUTIONY, 96 );
115 img.SetOption( wxIMAGE_OPTION_RESOLUTIONUNIT, wxIMAGE_RESOLUTION_INCHES );
117 wxMemoryOutputStream out;
118 img.SaveFile( out, wxBITMAP_TYPE_PNG );
121 buf.SetBufSize( out.GetSize() );
122 out.CopyTo( buf.GetData(), out.GetSize() );
123 buf.SetDataLen( out.GetSize() );
130inline std::set<std::string>
LoadTokenSet(
const std::string& aFileName )
132 std::set<std::string> tokens;
133 std::ifstream file( aFileName );
136 while( std::getline( file, line ) )
138 while( !line.empty() && ( line.back() ==
'\r' || line.back() ==
' ' ) )
142 tokens.insert( line );
151inline std::vector<std::string>
UnknownSexprHeads(
const std::string& aContent,
const std::set<std::string>& aKnown,
152 const std::set<std::string>& aHarmless = {} )
154 std::vector<std::string>
unknown;
158 if( !aKnown.count( head ) && !aHarmless.count( head ) )
What an export to a given target will keep, approximate, drop, or block.
bool IsLossy() const
True if anything is approximated or dropped. This is what triggers the lossy warning.
bool IsBlocked() const
True if some feature makes the target impossible. The user cannot export anyway.
const std::vector< COMPAT_ENTRY > & Entries() const
DOWNGRADE_BUCKET
What happens to a feature when we export to an older KiCad.
@ LOWER
Approximated down to a simpler equivalent.
@ DROP
No equivalent, left out.
std::string StripSexprStrings(const std::string &aText)
Drop quoted strings so a token inside a text value cannot cause a false refusal.
std::set< std::string > ExtractSexprNodeHeads(const std::string &aText)
Every lowercase node head in the text, e.g. for checking output against a release keyword set.
const DOWNGRADE_TARGET * FindDowngradeTarget(const wxString &aNameOrId)
Match a user-supplied target string against name or stable id, case-insensitively.
Test utilities for timestamps.
std::set< std::string > LoadTokenSet(const std::string &aFileName)
Read a release keyword file from qa/data/downgrade, one token per line.
void CheckTransformCoverage(const COMPATIBILITY_REPORT &aReport, int aTargetVersion, std::initializer_list< EXPECTED_DOWNGRADE_FEATURE > aFeatures, bool aDropInsteadOfApproximate)
const DOWNGRADE_TARGET & RequireDowngradeTarget(const wxString &aId)
wxMemoryBuffer MakePngWithFractionalPixelsPerCm()
A tiny PNG whose embedded resolution gives a fractional pixels/cm, so the legacy truncating PPI diffe...
std::vector< std::string > UnknownSexprHeads(const std::string &aContent, const std::set< std::string > &aKnown, const std::set< std::string > &aHarmless={})
Every node head in the serialized text that is not in the known or harmless sets.
One line in the compatibility report.
An older KiCad release we can export a project back to.
bool m_keepUnderOmitPolicy
Mirrors BOARD_RULE::m_keepUnderOmitPolicy.
DOWNGRADE_BUCKET m_bucket
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_TEST_CONTEXT("Test Clearance")
BOOST_CHECK_EQUAL(result, "25.4")