diff --git a/qa/unittests/eeschema/test_netlist_exporter_spice.cpp b/qa/unittests/eeschema/test_netlist_exporter_spice.cpp index 0e12f572cb..5bac536132 100644 --- a/qa/unittests/eeschema/test_netlist_exporter_spice.cpp +++ b/qa/unittests/eeschema/test_netlist_exporter_spice.cpp @@ -175,6 +175,21 @@ public: TEST_NETLIST_EXPORTER_FIXTURE::TestNetlist( aBaseName ); } + void TestOpPoint( double aRefValue, const std::string& aVectorName, double aMaxRelError = 1e-2 ) + { + BOOST_TEST_CONTEXT( "Vector name: " << aVectorName ) + { + NGSPICE* ngspice = static_cast( m_simulator.get() ); + + std::vector vector = ngspice->GetRealPlot( aVectorName ); + + BOOST_REQUIRE_EQUAL( vector.size(), 1 ); + + double maxError = abs( aRefValue * aMaxRelError ); + BOOST_CHECK_LE( abs( vector[0] - aRefValue ), aMaxRelError ); + } + } + void TestPoint( const std::string& aXVectorName, double aXValue, const std::map aTestVectorsAndValues, double aMaxRelError = 1e-2 ) @@ -208,7 +223,7 @@ public: BOOST_REQUIRE_LT( i, xVector.size() ); - for( auto&& [vectorName, refValue] : aTestVectorsAndValues ) + for( auto& [vectorName, refValue] : aTestVectorsAndValues ) { std::vector yVector = ngspice->GetMagPlot( vectorName ); @@ -233,16 +248,16 @@ public: void TestTranPoint( double aTime, const std::map aTestVectorsAndValues, - double aMaxAbsError = 1e-2 ) + double aMaxRelError = 1e-2 ) { - TestPoint( "time", aTime, aTestVectorsAndValues, aMaxAbsError ); + TestPoint( "time", aTime, aTestVectorsAndValues, aMaxRelError ); } void TestACPoint( double aFrequency, const std::map aTestVectorsAndValues, - double aMaxAbsError = 1e-2 ) + double aMaxRelError = 1e-2 ) { - TestPoint( "frequency", aFrequency, aTestVectorsAndValues, aMaxAbsError ); + TestPoint( "frequency", aFrequency, aTestVectorsAndValues, aMaxRelError ); } wxString GetResultsPath( bool aTest = false ) @@ -333,6 +348,15 @@ BOOST_AUTO_TEST_CASE( Rlc ) } +BOOST_AUTO_TEST_CASE( Potentiometers ) +{ + TestNetlist( "potentiometers" ); + TestOpPoint( 0.5, "V(/out1)" ); + TestOpPoint( 0.3, "V(/out2)" ); + TestOpPoint( 0.1, "V(/out3)" ); +} + + BOOST_AUTO_TEST_CASE( Tlines ) { LOCALE_IO dummy;