<commit_before>#ifndef SDLUT_TEST_COMMON
#define SDLUT_TEST_COMMON


//This header is the common structure to all tests.
// A test coder can extend these classes to implement easy checks
#include "SDL.hh"

#include "Logger.hh"
using namespace RAGE;

using namespace SDLut;



class ArgParser
{
  std::vector<std::string> args;

public:
  ArgParser(int argc, char* argv[])
  {
      for (int i = 0; i < argc; ++i )
      {
        args.push_back(std::string(argv[i]));
      }
  }

  ~ArgParser() {}

  std::string get(unsigned int index)
  {
      std::string result("");

      if ( args.size()>index)
      {
          if ( args.at(index) != "nogl" && args.at(index) != "auto")
          {
              result = args.at(index);
          }
          else if ( args.size() > index +1)
          {
              result = get(index+1);
          }
          //else // no more args
          //{
          //    result = "";
          //}
      }

      return result;
  }



  bool isSDL() const
  {
	return !isOGL();
  }

  bool isOGL() const
  {
#ifdef WK_OPENGL_FOUND
	  for (unsigned int i = 0; i < args.size(); i++)
	  {
		  if ( args[i] == "nogl" )
		  {
			  return false;
		  }
	  }
	  return true;

#else
      return false;
#endif
  }

  bool isAuto() const
  {
	  for (unsigned int i = 0; i < args.size(); i++)
	  {
		  if ( args[i] == "auto" )
		  {
			  return true;
		  }
	  }
	  return false;
  }

  std::string getcmd()
  {
      return args[0];
  }

};






//engine holding the test code to be run
//TODO : Maybe we can simplify with only one engine, to assert render only ???
class AssertEngine
{
//to be albe to set error, even while rendering
mutable std::string m_error;
mutable int m_exitstatus;

    unsigned int m_numrender;
    unsigned int m_maxrender;

protected :

//to be able to write in log, even while rendering
mutable    Logger & m_log;



    public :
    ///max_render = 0 means it will run forever
    AssertEngine( Logger & log, const ArgParser & ap ) : m_error("OK"), m_exitstatus(0), m_numrender(0), m_maxrender(0),m_log(log)
    {
        if ( ap.isAuto() ) m_maxrender = 1;
    }

    ~AssertEngine() {}

    //Will log an Error string and exit
    void setError(int status, std::string err) const
    {
        m_exitstatus = status;
        m_error = err;
        m_log << nl<< "ERROR : " << err ;
        //return App::getInstance().requestTermination(status);
    }

    //init and resize code is often the same ( but not always )
	virtual bool assertinit(int width, int height)
	{
	    return assertresize(width,height);<commit_msg> adding new line after arror display <commit_after>#ifndef SDLUT_TEST_COMMON
#define SDLUT_TEST_COMMON


//This header is the common structure to all tests.
// A test coder can extend these classes to implement easy checks
#include "SDL.hh"

#include "Logger.hh"
using namespace RAGE;

using namespace SDLut;



class ArgParser
{
  std::vector<std::string> args;

public:
  ArgParser(int argc, char* argv[])
  {
      for (int i = 0; i < argc; ++i )
      {
        args.push_back(std::string(argv[i]));
      }
  }

  ~ArgParser() {}

  std::string get(unsigned int index)
  {
      std::string result("");

      if ( args.size()>index)
      {
          if ( args.at(index) != "nogl" && args.at(index) != "auto")
          {
              result = args.at(index);
          }
          else if ( args.size() > index +1)
          {
              result = get(index+1);
          }
          //else // no more args
          //{
          //    result = "";
          //}
      }

      return result;
  }



  bool isSDL() const
  {
	return !isOGL();
  }

  bool isOGL() const
  {
#ifdef WK_OPENGL_FOUND
	  for (unsigned int i = 0; i < args.size(); i++)
	  {
		  if ( args[i] == "nogl" )
		  {
			  return false;
		  }
	  }
	  return true;

#else
      return false;
#endif
  }

  bool isAuto() const
  {
	  for (unsigned int i = 0; i < args.size(); i++)
	  {
		  if ( args[i] == "auto" )
		  {
			  return true;
		  }
	  }
	  return false;
  }

  std::string getcmd()
  {
      return args[0];
  }

};






//engine holding the test code to be run
//TODO : Maybe we can simplify with only one engine, to assert render only ???
class AssertEngine
{
//to be albe to set error, even while rendering
mutable std::string m_error;
mutable int m_exitstatus;

    unsigned int m_numrender;
    unsigned int m_maxrender;

protected :

//to be able to write in log, even while rendering
mutable    Logger & m_log;



    public :
    ///max_render = 0 means it will run forever
    AssertEngine( Logger & log, const ArgParser & ap ) : m_error("OK"), m_exitstatus(0), m_numrender(0), m_maxrender(0),m_log(log)
    {
        if ( ap.isAuto() ) m_maxrender = 1;
    }

    ~AssertEngine() {}

    //Will log an Error string and exit
    void setError(int status, std::string err) const
    {
        m_exitstatus = status;
        m_error = err;
        m_log << nl<< "ERROR : " << err << nl ;
        //return App::getInstance().requestTermination(status);
    }

    //init and resize code is often the same ( but not always )
	virtual bool assertinit(int width, int height)
	{
	    return assertresize(width,height);
{'fraction_non_alphanumeric': 0.12788906009244994, 'fraction_numerical': 0.00423728813559322, 'mean_word_length': 2.1396614268440146, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7452394', 'n_tokens_mistral': 1817, 'n_tokens_neox': 1701, 'n_words': 517}