20#include <boost/test/unit_test.hpp>
49 wxString( wxS(
"bom-.csv" ) ) );
52 wxString( wxS(
"out-A_B.zip" ) ) );
54 wxString( wxS(
"bom-A/B.csv" ) ) );
60 job.
FromJson( nlohmann::json{ {
"variant",
"Variant A" } } );
78 nlohmann::json missingKeys = nlohmann::json::object();
82 nlohmann::json odbJson;
86 BOOST_CHECK( !odbJson.at(
"check_zones" ).get<
bool>() );
87 BOOST_CHECK( odbJson.at(
"board_metadata" ).get<
bool>() );
92 nlohmann::json ipcJson;
96 BOOST_CHECK( !ipcJson.value(
"check_zones",
true ) );
100 nlohmann::json emptyVariant = { {
"variant",
"" } };
113 std::ifstream odbFile( fixtureDir /
"odb_job_v10.json" );
114 std::ifstream ipcFile( fixtureDir /
"ipc2581_job_v10.json" );
117 nlohmann::json odbV10 = nlohmann::json::parse( odbFile );
118 nlohmann::json ipcV10 = nlohmann::json::parse( ipcFile );
122 nlohmann::json odbRoundTrip;
123 odb.
ToJson( odbRoundTrip );
125 for(
auto it = odbV10.begin(); it != odbV10.end(); ++it )
127 BOOST_CHECK_MESSAGE( odbRoundTrip.at( it.key() ) == it.value(),
"ODB key " << it.key() );
132 nlohmann::json ipcRoundTrip;
133 ipc.
ToJson( ipcRoundTrip );
135 for(
auto it = ipcV10.begin(); it != ipcV10.end(); ++it )
137 BOOST_CHECK_MESSAGE( ipcRoundTrip.at( it.key() ) == it.value(),
"IPC key " << it.key() );
140 BOOST_CHECK( odbRoundTrip.contains(
"variant_names" ) );
141 BOOST_CHECK( ipcRoundTrip.contains(
"variant_names" ) );
162 job.
FromJson( nlohmann::json{ {
"mode",
"FABRICATION" },
163 {
"sections",
"KE" },
164 {
"net_names",
"anonymize" },
165 {
"ref_des",
"omit" } } );
182 unset.
FromJson( nlohmann::json{ {
"mode",
"" }, {
"net_names",
"" }, {
"ref_des",
"" } } );
189 bogus.
FromJson( nlohmann::json{ {
"mode",
"bogus" } } );
196 bogusOdb.
FromJson( nlohmann::json{ {
"data_set",
"bogus" } } );
214 ipc.
FromJson( nlohmann::json{ {
"field_bom_map.mfg_pn",
"IPC-MPN" } } );
215 nlohmann::json ipcJson;
217 BOOST_CHECK_EQUAL( ipcJson.at(
"field_bom_map.mfg_pn" ).get<std::string>(),
"IPC-MPN" );
223 nlohmann::json options = { {
"origin",
"aux" },
224 {
"product_name",
"Fab Rev A" },
225 {
"data_set",
"assembly" },
226 {
"sections",
"ACOP" },
227 {
"board_metadata",
false },
228 {
"net_names",
"anonymize" },
229 {
"layers", nlohmann::json::array( { { {
"layer",
"F.Cu" },
230 {
"include",
false },
231 {
"odb_name",
"front_copper" },
232 {
"odb_type",
"SIGNAL" } } } ) } };
238 for(
auto it = options.begin(); it != options.end(); ++it )
239 BOOST_CHECK_MESSAGE(
roundTrip.contains( it.key() ) &&
roundTrip[it.key()] == it.value(), it.key() );
243 nlohmann::json again;
253 {
"layers", nlohmann::json::array( { { {
"layer",
"F.Cu" }, {
"include",
"not-a-boolean" } },
254 { {
"layer",
"B.Cu" }, {
"odb_name", 12 } },
255 { {
"layer",
"In1.Cu" }, {
"odb_type",
false } } } ) } } );
267 job.
m_layerOverrides.push_back( {
F_Cu,
true, wxString::FromUTF8(
"Résumé_日本" ), wxS(
"SIGNAL" ) } );
271 struct RESTORE_LOCALE
273 std::string m_previous = std::setlocale( LC_CTYPE,
nullptr );
274 ~RESTORE_LOCALE() { std::setlocale( LC_CTYPE, m_previous.c_str() ); }
288 nlohmann::json options = { {
"check_zones",
true } };
386 job.
FromJson( nlohmann::json{ {
"mode",
"USERDEF" }, {
"sections",
"" }, {
"custom_sections",
true } } );
388 nlohmann::json saved;
390 BOOST_CHECK( saved.value(
"custom_sections",
false ) );
400 legacy.
FromJson( nlohmann::json{ {
"sections",
"" } } );
401 nlohmann::json legacyJson;
402 legacy.
ToJson( legacyJson );
403 BOOST_CHECK( !legacyJson.value(
"custom_sections",
false ) );
407 legacyNonempty.
FromJson( nlohmann::json{ {
"sections",
"K" } } );
void FromJson(const nlohmann::json &aJson) override
DATA_SET
Columns of the IPC-2581C function mode table, Table 4 p 80.
static std::string DataSetToken(DATA_SET aDataSet)
Lower case token that the job file and the CLI use for aDataSet Empty when it has none.
void ToJson(nlohmann::json &aJson) const override
std::optional< wxString > m_sections
Section key that replaces the optional sections of the data set Unset lets the data set select them a...
std::vector< wxString > m_variantNames
void FromJson(const nlohmann::json &aJson) override
VARIANT_PACKAGING m_variantPackaging
std::vector< ODB_LAYER_OVERRIDE > m_layerOverrides
void FromJson(const nlohmann::json &aJson) override
std::vector< wxString > m_variantNames
std::vector< wxString > m_variantNames
virtual void FromJson(const nlohmann::json &j)
virtual void ToJson(nlohmann::json &j) const
static bool empty(const wxTextEntryBase *aCtrl)
std::string GetTestDataRootDir()
wxString GetDefaultVariantName()
wxString ExpandVariantOutputPath(const wxString &aPath, const wxString &aVariantToken)
wxString GetVariantFileToken(const wxString &aVariantName)
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_CHECK(res.column_datatype(0)==SQL_NUMERIC||res.column_datatype(0)==SQL_DECIMAL)
BOOST_REQUIRE_EQUAL(rows.size(), 1)
BOOST_CHECK_EQUAL(std::any_cast< std::string >(rows[0].at("val")), "12345678901234567.89")
BOOST_REQUIRE(res.columns()==1)
static void roundTrip(const DIFF_VALUE &aValue)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(OdbVariantFileTokenKeepsNamesAndRemovesSeparators)