//----------------------------------------------------------------------------
///
/// \file   main.cpp
///
/// \brief  main file for pinmux
///
/// \date   20180129
/// \author Maximilian Seesslen <mes@seesslen.net>
///
//----------------------------------------------------------------------------


//---Documentation------------------------------------------------------------


//---Includes -----------------------------------------------------------------


//---General--------------------------

#if defined ( CATCH2 )
#include <catch2/catch_test_macros.hpp>
#elif defined ( CATCH )
#include <catch/catch.hpp>
#else
#error "Either 'catch' or 'catch2' has to be installed"
#endif
#include <QDir>

//--- Own ----------------------------

#include "../src/board.h"
#include "../src/app.h"
#include "../src/pinmux.h"
#include "writerPlatform.h"
#include "formaterCpp.h"

#define TEST_ALL
#define STOP_ON_FAIL

//---Implementation------------------------------------------------------------


TEST_CASE( "Writer", "[default]" ) {
   CPinmux pinmux;
   CApp app;
   CBoard board;

   SECTION( "Header" )
   {
      app.clear();
      board.clear();
      app.setBoardId("app");

      app.loadFile( CURRENT_SOURCE_DIR "/tests/apps/candis.json" );
      board.loadFile( SOURCE_DIR "/../arena/boards/stm32g441kb.json" );
      pinmux.setBoardApp(board, app);

      int status=0;
      try
      {
         pinmux.resolveApp( );
         CConstructorPool constructors;
         constructors.loadFile( SOURCE_DIR "/../arena/frameworks/biwak.json" );
         CWriterPlatform writer(pinmux, constructors, QDir().absolutePath() );
         writer.writeHeader( /*"header.hpp" */ );
         //writer.writeImplementation("header.cpp");
      }
      catch(...)
      {
         status=1;
      }
      REQUIRE ( status == 0);
   }
}

//---fin-----------------------------------------------------------------------
