Skip to content
Snippets Groups Projects
Commit 57a7e5f2 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

Start file Assert.h

parent 2f8ed87c
No related branches found
No related tags found
No related merge requests found
......@@ -66,6 +66,9 @@ include(CheckCompiler)
if(ZERO_TOLERANCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wfatal-errors")
endif()
if(BORNAGAIN_GUI)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_MESSAGELOGCONTEXT=ON")
endif()
include(BornAgainConfiguration)
include(BornAgainPolicy)
include(GeneratePythonDocs)
......
// ************************************************************************** //
//
// BornAgain: simulate and fit scattering at grazing incidence
//
//! @file Core/Basics/Assert.h
//! @brief Defines the macro ASSERT.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************** //
#ifndef BORNAGAIN_CORE_BASICS_ASSERT_H
#define BORNAGAIN_CORE_BASICS_ASSERT_H
#ifdef BORNAGAIN_GUI
#include <QtGlobal>
#define ASSERT(condition) \
if (!(condition)) \
qFatal("assertion failed");
#else // The non-GUI case is used by our test suite
#include <iostream>
#define ASSERT(condition) \
if (!(condition)) { \
std::cerr << "assertion failed" << std::endl; \
exit(1); \
}
#endif // BORNAGAIN_GUI
#endif // BORNAGAIN_CORE_BASICS_ASSERT_H
#include "Core/Basics/Assert.h"
#include "Tests/GTestWrapper/google_test.h"
class TestAssert : public ::testing::Test
{
};
TEST_F(TestAssert, Assert)
{
EXPECT_NO_THROW(ASSERT(1));
EXPECT_EXIT(ASSERT(0), ::testing::ExitedWithCode(1), "assertion failed");
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment