Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) TestReversi

 

TestReversi is a tool to test the Reversi class.

 

 

 

 

 

Downloads

 

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./ToolTestReversi/ToolTestReversiConsole.pro

 

include(../../DesktopApplication.pri)

#Libs
include(../../Libraries/Boost.pri)
include(../../Libraries/Fparser.pri)

#Console
include(../../Classes/CppAbout/CppAbout.pri)
include(../../Classes/CppFileIo/CppFileIo.pri)
include(../../Classes/CppHelp/CppHelp.pri)
include(../../Classes/CppMenuDialog/CppMenuDialog.pri)
include(../../Classes/CppRichelBilderbeekProgram/CppRichelBilderbeekProgram.pri)
include(../../Classes/CppTrace/CppTrace.pri)

#Desktop
include(../../Classes/CppQtAboutDialog/CppQtAboutDialog.pri)
include(../../Classes/CppQtHideAndShowDialog/CppQtHideAndShowDialog.pri)

#Specific for this application
#Console
include(../../Classes/CppReversi/CppReversi.pri)
include(../../Tools/ToolTestReversi/ToolTestReversiConsole.pri)

SOURCES +=  \
    main.cpp

OTHER_FILES += \
    ToolTestReversiConsole.pri

 

 

 

 

 

Qt project file: ./ToolTestReversi/ToolTestReversiDesktop.pro

 

include(../../DesktopApplication.pri)
include(../../Libraries/Boost.pri)
include(../../Libraries/Fparser.pri)
include(../../Libraries/GeneralConsole.pri)
include(../../Libraries/GeneralDesktop.pri)

#Specific for this application
#Console
include(../../Classes/CppCanvas/CppCanvas.pri)
include(../../Classes/CppDotMatrix/CppDotMatrix.pri)
include(../../Classes/CppReversi/CppReversi.pri)
include(../../Classes/CppTextCanvas/CppTextCanvas.pri)

#Desktop
include(../../Classes/CppQtReversi/CppQtReversi.pri)
include(ToolTestReversiDesktop.pri)

SOURCES += qtmain.cpp

 

 

 

 

 

./ToolTestReversi/ToolTestReversiConsole.pri

 

INCLUDEPATH += \
    ../../Tools/ToolTestReversi

SOURCES += \
    ../../Tools/ToolTestReversi/testreversimenudialog.cpp \
    ../../Tools/ToolTestReversi/testreversimaindialog.cpp

HEADERS += \
    ../../Tools/ToolTestReversi/testreversimenudialog.h \
    ../../Tools/ToolTestReversi/testreversimaindialog.h

 

 

 

 

 

./ToolTestReversi/ToolTestReversiDesktop.pri

 

include(../../Tools/ToolTestReversi/ToolTestReversiConsole.pri)

SOURCES += \
    ../../Tools/ToolTestReversi/qttestreversimaindialog.cpp

FORMS += \
    ../../Tools/ToolTestReversi/qttestreversimaindialog.ui

HEADERS += \
    ../../Tools/ToolTestReversi/qttestreversimaindialog.h

 

 

 

 

 

./ToolTestReversi/main.cpp

 

#include "testreversimenudialog.h"

int main(int argc, char * argv[])
{
  const std::vector<std::string> args { ribi::MenuDialog::ConvertArguments(argc,argv) };
  return ribi::TestReversiMenuDialog().Execute(args);
}

 

 

 

 

 

./ToolTestReversi/qtmain.cpp

 

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include <QApplication>
#include "qttestreversimaindialog.h"
#pragma GCC diagnostic pop

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  ribi::QtTestReversiMainDialog w;
  w.show();
  return a.exec();
}

 

 

 

 

 

./ToolTestReversi/qttestreversimaindialog.h

 

#ifndef QTTESTREVERSIMAINDIALOG_H
#define QTTESTREVERSIMAINDIALOG_H

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include <boost/shared_ptr.hpp>

#include "qthideandshowdialog.h"
#pragma GCC diagnostic pop

namespace Ui {
  class QtTestReversiMainDialog;
}

namespace ribi {

namespace reversi { struct QtWidget; }

class QtTestReversiMainDialog : public QtHideAndShowDialog
{
  Q_OBJECT

public:
  explicit QtTestReversiMainDialog(QWidget *parent = 0);
  QtTestReversiMainDialog(const QtTestReversiMainDialog&) = delete;
  QtTestReversiMainDialog& operator=(const QtTestReversiMainDialog&) = delete;
  ~QtTestReversiMainDialog();


private:
  Ui::QtTestReversiMainDialog *ui;
  boost::shared_ptr<reversi::QtWidget> m_reversi;
};

} //~namespace ribi

#endif // QTTESTREVERSIMAINDIALOG_H

 

 

 

 

 

./ToolTestReversi/qttestreversimaindialog.cpp

 

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include "qttestreversimaindialog.h"
#include "qtreversiwidget.h"
#include "ui_qttestreversimaindialog.h"
#pragma GCC diagnostic pop

ribi::QtTestReversiMainDialog::QtTestReversiMainDialog(QWidget *parent) :
  QtHideAndShowDialog(parent),
  ui(new Ui::QtTestReversiMainDialog),
  m_reversi(new reversi::QtWidget)
{
  ui->setupUi(this);

  ui->layout->addWidget(m_reversi.get());
}

ribi::QtTestReversiMainDialog::~QtTestReversiMainDialog()
{
  delete ui;
}

 

 

 

 

 

./ToolTestReversi/testreversimaindialog.h

 

#ifndef TESTREVERSIMAINDIALOG_H
#define TESTREVERSIMAINDIALOG_H

#include <string>
#include <vector>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#include <boost/scoped_ptr.hpp>
#include "about.h"
#pragma GCC diagnostic pop

struct QImage;

namespace ribi {

struct TestReversiMainDialog
{
  TestReversiMainDialog();

  ///Start a Reversi game
  void Execute();

  private:

  #ifndef NDEBUG
  static void Test() noexcept;
  #endif
};

} //~namespace ribi

#endif // TESTREVERSIMAINDIALOG_H

 

 

 

 

 

./ToolTestReversi/testreversimaindialog.cpp

 

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#include "testreversimaindialog.h"

#include <stdexcept>

#include <boost/numeric/conversion/cast.hpp>

#include "reversiboard.h"
#include "fileio.h"
#include "testtimer.h"
#include "trace.h"
#pragma GCC diagnostic pop

ribi::TestReversiMainDialog::TestReversiMainDialog()
{
  #ifndef NDEBUG
  Test();
  #endif
}

void ribi::TestReversiMainDialog::Execute()
{

}

#ifndef NDEBUG
void ribi::TestReversiMainDialog::Test() noexcept
{
  {
    static bool is_tested{false};
    if (is_tested) return;
    is_tested = true;
  }
  const TestTimer test_timer(__func__,__FILE__,1.0);
}
#endif

 

 

 

 

 

./ToolTestReversi/testreversimenudialog.h

 

#ifndef TESTREVERSIMENUDIALOG_H
#define TESTREVERSIMENUDIALOG_H

#include <string>
#include <vector>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#include <boost/scoped_ptr.hpp>

#include "about.h"
#include "menudialog.h"
#pragma GCC diagnostic pop

namespace ribi {

struct TestReversi;

struct TestReversiMenuDialog final : public MenuDialog
{
  TestReversiMenuDialog();
  ~TestReversiMenuDialog() noexcept {}
  int ExecuteSpecific(const std::vector<std::string>& argv) noexcept override;

  About GetAbout() const noexcept override;
  Help GetHelp() const noexcept override;
  boost::shared_ptr<const Program> GetProgram() const noexcept override;
  std::string GetVersion() const noexcept override;
  std::vector<std::string> GetVersionHistory() const noexcept override;

  private:

  #ifndef NDEBUG
  static void Test() noexcept;
  #endif
};

} //~namespace ribi

#endif // TESTREVERSIMENUDIALOG_H

 

 

 

 

 

./ToolTestReversi/testreversimenudialog.cpp

 

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include "testreversimenudialog.h"

#include <algorithm>
#include <fstream>
#include <iostream>
#include <iterator>

#include <boost/lexical_cast.hpp>

#include "reversiboard.h"
#include "richelbilderbeekprogram.h"
#include "testreversimaindialog.h"
#include "testtimer.h"
#include "fileio.h"
#include "trace.h"
#pragma GCC diagnostic pop

ribi::TestReversiMenuDialog::TestReversiMenuDialog()
{
  #ifndef NDEBUG
  Test();
  #endif
}

int ribi::TestReversiMenuDialog::ExecuteSpecific(const std::vector<std::string>& argv) noexcept
{
  const int argc = static_cast<int>(argv.size());
  if (argc != 1 )
  {
    std::cout << GetHelp() << '\n';
    return 1;
  }
  TestReversiMainDialog d;
  d.Execute();
  return 0;
}

ribi::About ribi::TestReversiMenuDialog::GetAbout() const noexcept
{
  About a(
    "Richel Bilderbeek",
    "TestReversi",
    "",
    "",
    "",
    "http://www.richelbilderbeek.nl/ToolTestReversi.htm",
    GetVersion(),
    GetVersionHistory());
  a.AddLibrary("reversi::Board version: " + reversi::Board::GetVersion());
  return a;
}

boost::shared_ptr<const ribi::Program> ribi::TestReversiMenuDialog::GetProgram() const noexcept
{
  const boost::shared_ptr<const ribi::Program> p(new ProgramTestReversi);
  assert(p);
  return p;
}

std::string ribi::TestReversiMenuDialog::GetVersion() const noexcept
{
  return "1.1";
}

std::vector<std::string> ribi::TestReversiMenuDialog::GetVersionHistory() const noexcept
{
  return {
    "2006-12-13: Version 1.0: initial C++ Builder version, called 'TestReversi'",
    "2013-xx-xx: Version 1.1: start of port to Qt Creator",
  };
}

ribi::Help ribi::TestReversiMenuDialog::GetHelp() const noexcept
{
  return ribi::Help(
    "TestReversi",
    "Tool to test the reversi classes",
    {
    },
    {
    }
  );
}

#ifndef NDEBUG
void ribi::TestReversiMenuDialog::Test() noexcept
{
  {
    static bool is_tested{false};
    if (is_tested) return;
    is_tested = true;
  }
  const TestTimer test_timer(__func__,__FILE__,1.0);
}
#endif

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml