//----------------------------------------------------------------------------
///
/// \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

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

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

#define TEST_ALL
#define STOP_ON_FAIL

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


TEST_CASE( "Variant", "[default]" ) {
   CApp app;

   SECTION( "Variant" )
   {
      const char *appString=
      R"JSON(
                     {
                         "name": "canio",
                         "periphery": [
                            { "type": "GPIO", "name": "1", "variant": "myVariant"}
                          ]
                     }
            )JSON";

      app.clear();
      app.setBoardId("myboard");
      app.loadByteArray( QByteArray(appString ), "intern" );
      REQUIRE( app.getReferenceList().count() == 0);

      app.clear();
      app.setVariant("myVariant");
      app.loadByteArray( QByteArray(appString ), "intern" );
      REQUIRE( app.getReferenceList().count() == 1);

      app.clear();
      app.setVariant("myVariantFoo");
      app.loadByteArray( QByteArray(appString ), "intern" );
      REQUIRE( app.getReferenceList().count() == 0);
   }
}


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