24 std::ifstream file( aPath );
27 throw std::runtime_error(
"Cannot read downgrade fixture: " + aPath );
29 return { std::istreambuf_iterator<char>( file ), std::istreambuf_iterator<char>() };
60 auto root = parser.
Parse( aContent );
62 if( root && root->IsList() )
77 if(
scale &&
scale->GetNumberOfChildren() == 2 )
88 throw std::runtime_error(
"Image has no numeric scale: " + aUuid );
92 throw std::runtime_error(
"Serialized image is missing: " + aUuid );
107 if( ( aParent ==
"kicad_pcb" || aParent ==
"kicad_sch" || aParent ==
"footprint" || aParent ==
"kicad_symbol_lib" )
108 && head ==
"generator_version" )
115 if( aParent !=
"pcbplotparams" )
118 if( head ==
"pngdpi" || head ==
"pngantialias" )
128 if( head ==
"plotinvisibletext" )
135 return ( head ==
"hpglpennumber" && number == 1 ) || ( head ==
"hpglpenspeed" && number == 20 )
136 || ( head ==
"hpglpendiameter" && number == 15 );
141 const std::string& aPath =
"",
const std::string& aParent =
"",
147 const std::string
path = aPath +
"/" + head;
148 std::vector<const SEXPR::SEXPR*>
expected;
149 std::vector<const SEXPR::SEXPR*>
actual;
160 actual.push_back( child );
164 return path +
": child count " + std::to_string(
expected.size() )
165 +
" != " + std::to_string(
actual.size() );
167 for(
size_t i = 0; i <
expected.size(); ++i )
169 std::string difference =
172 if( !difference.empty() )
187 ( aParent ==
"at" || aParent ==
"xy" || aParent ==
"start" || aParent ==
"end" || aParent ==
"mid" )
188 && ( aIndex == 1 || aIndex == 2 );
198 return aPath +
": expected " + aExpected.
AsString() +
", got " + aActual.
AsString();
209 throw std::runtime_error(
"Empty downgrade golden or output" );
std::unique_ptr< SEXPR > Parse(const std::string &aString)
SEXPR_VECTOR const * GetChildren() const
std::string const & GetSymbol() const
std::string AsString(size_t aLevel=0) const
size_t GetNumberOfChildren() const
int64_t GetLongInteger() const
std::string const & GetString() const
SEXPR * GetChild(size_t aIndex) const
Test utilities for timestamps.
std::string GoldenNodeHead(const SEXPR::SEXPR &aNode)
std::string GoldenFileDifference(const std::string &aExpected, const std::string &aActual)
std::string ReadGoldenText(const std::string &aPath)
bool IgnoreGoldenNode(const SEXPR::SEXPR &aNode, const std::string &aParent)
std::string GoldenSexprDifference(const SEXPR::SEXPR &aExpected, const SEXPR::SEXPR &aActual, const std::string &aPath="", const std::string &aParent="", size_t aIndex=0)
const SEXPR::SEXPR * FindGoldenChild(const SEXPR::SEXPR &aNode, const std::string &aHead)
double SerializedImageScale(const std::string &aContent, const std::string &aUuid)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
VECTOR3I expected(15, 30, 45)