Files
Ivan Krysak 7d235f4fd0 Enforce licence header consistency
Also do some basic cleanup: capitalize first letters, add `.`
at the end of the sentences, and so on.
2023-07-03 15:23:10 +00:00

41 lines
980 B
C++

/// \file ClassSentinel.cpp
//
// This file is distributed under the MIT License. See LICENSE.md for details.
//
#define BOOST_TEST_MODULE EarlyFunctionAnalysis
bool init_unit_test();
#include "boost/test/unit_test.hpp"
#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
}