Files
Cataclysm-DDA/tests/value_ptr_test.cpp
T
Binrui Dong 9fdb7ef59c Run IWYU
* Change _ctype.h and __locale to cctype and clocale

* Change _wctype.h to cwctype in game.cpp

* Change __functional_base to functional

* Remove libcxx internal headers

* Remove UNIX system headers

* Fix clang-tidy error with -nostdinc++
2021-02-06 00:18:41 -05:00

48 lines
1.1 KiB
C++

#include <type_traits>
#include "catch/catch.hpp"
#include "value_ptr.h"
TEST_CASE( "value_ptr copy constructor", "[value_ptr]" )
{
cata::value_ptr<int> a = cata::make_value<int>( 7 );
REQUIRE( !!a );
cata::value_ptr<int> b( a );
CHECK( !!a );
CHECK( !!b );
a.reset( nullptr );
CHECK( !a );
CHECK( !!b );
}
TEST_CASE( "value_ptr copy assignment", "[value_ptr]" )
{
cata::value_ptr<int> a = cata::make_value<int>( 7 );
REQUIRE( !!a );
cata::value_ptr<int> b;
REQUIRE( !b );
b = a;
CHECK( !!a );
CHECK( !!b );
a.reset( nullptr );
CHECK( !a );
CHECK( !!b );
}
TEST_CASE( "value_ptr move constructor", "[value_ptr]" )
{
cata::value_ptr<int> a = cata::make_value<int>( 7 );
REQUIRE( !!a );
cata::value_ptr<int> b( std::move( a ) );
CHECK( !a ); // NOLINT(bugprone-use-after-move)
CHECK( !!b );
}
TEST_CASE( "value_ptr move assignment", "[value_ptr]" )
{
cata::value_ptr<int> a = cata::make_value<int>( 7 );
cata::value_ptr<int> b = std::move( a );
CHECK( !a ); // NOLINT(bugprone-use-after-move)
CHECK( !!b );
}