Files
revng-revng/tests/Unit/ClassSentinel.cpp
T
Alessandro Di Federico 6ae3b6f22f Whitespace and other minor changes
* `GeneratedCodeBasicInfo::getCSVUsedByHelperCall` and
  `GeneratedCodeBasicInfo::extractCSVs`: make the call argument an
  `Instruction`.
* Introduce `blockByName`
* Introduce `getUniqueUser`.
* Fix linking issues.
2019-05-14 16:27:13 +02:00

44 lines
1.0 KiB
C++

/// \file ClassSentinel.cpp
/// \brief Tests for ClassSentinel
//
// This file is distributed under the MIT License. See LICENSE.md for details.
//
// Boost includes
#define BOOST_TEST_MODULE StackAnalysis
bool init_unit_test();
#include <boost/test/unit_test.hpp>
// Local libraries includes
#include "revng/Support/ClassSentinel.h"
#include "revng/UnitTestHelpers/UnitTestHelpers.h"
struct TestClass {
ClassSentinel Sentinel;
};
BOOST_AUTO_TEST_CASE(Sentinel) {
TestClass *DanglingPointer = nullptr;
{
TestClass Instance;
BOOST_TEST(!Instance.Sentinel.isMoved());
BOOST_TEST(!Instance.Sentinel.isDestroyed());
TestClass OtherInstance = std::move(Instance);
BOOST_TEST(Instance.Sentinel.isMoved());
BOOST_TEST(!Instance.Sentinel.isDestroyed());
DanglingPointer = &Instance;
}
#if !(defined(__OPTIMIZE__) || defined(__SANITIZE_ADDRESS__) \
|| (defined(__has_feature) && __has_feature(address_sanitizer)))
BOOST_TEST(DanglingPointer->Sentinel.isDestroyed());
#else
(void) DanglingPointer;
#endif
}