Re[3]: библиотека контрактов, сложности использования/сборки
От: niXman Ниоткуда https://github.com/niXman
Дата: 06.07.16 17:48
Оценка:
итак, disableinvariants.cpp имеет такое содержание:
#define CONTRACT_DISABLE_INVARIANTS
#include <contract/contract.hpp>

#include "contract_error.hpp"

#include <boost/test/unit_test.hpp>

namespace
{

void test_disable_invariants()
{
    contract (fun) { invariant(false); };
}

void test_disable_invariants_precondition()
{
    contract (fun) { precondition(false); };
}

void test_disable_invariants_postcondition()
{
    contract (fun) { postcondition(false); };
}

}

BOOST_AUTO_TEST_CASE(macro_disable_invariants)
{
    test::contract_handler_frame cframe;

    // expect disabled invariant
    BOOST_CHECK_NO_THROW(test_disable_invariants());

    // expect precondition to fail
    BOOST_CHECK_THROW(test_disable_invariants_precondition(),
                      test::contract_error);

    // expect postcondition to fail
    BOOST_CHECK_THROW(test_disable_invariants_postcondition(),
                      test::contract_error);
}

// Copyright Alexei Zakharov, 2013.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

ошибки пропадают, только если этот код изменить так?:
#define CONTRACT_DISABLE_INVARIANTS
#include <contract/contract.hpp>

//#include "contract_error.hpp"

//#include <boost/test/unit_test.hpp>

#if 0
namespace
{

void test_disable_invariants()
{
    contract (fun) { invariant(false); };
}

void test_disable_invariants_precondition()
{
    contract (fun) { precondition(false); };
}

void test_disable_invariants_postcondition()
{
    contract (fun) { postcondition(false); };
}

}

BOOST_AUTO_TEST_CASE(macro_disable_invariants)
{
    test::contract_handler_frame cframe;

    // expect disabled invariant
    BOOST_CHECK_NO_THROW(test_disable_invariants());

    // expect precondition to fail
    BOOST_CHECK_THROW(test_disable_invariants_precondition(),
                      test::contract_error);

    // expect postcondition to fail
    BOOST_CHECK_THROW(test_disable_invariants_postcondition(),
                      test::contract_error);
}
#endif
// Copyright Alexei Zakharov, 2013.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
пачка бумаги А4 стОит 2000 р, в ней 500 листов. получается, лист обычной бумаги стОит дороже имперского рубля =)
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.