forked from Alepha/Alepha
Bring in the mockination work and Truss from old.
It's all a mess -- not in the new unified form and namespace. I need to do a big cleanup pass.
This commit is contained in:
63
Truss/memory.test/test0.cc
Normal file
63
Truss/memory.test/test0.cc
Normal file
@ -0,0 +1,63 @@
|
||||
#include <Alepha/Truss/memory.h>
|
||||
|
||||
#include <Alepha/assert.h>
|
||||
|
||||
#include <Alepha/Mockination/MockFunction.h>
|
||||
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
inline namespace Test0
|
||||
{
|
||||
static void runTests();
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
runTests();
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
static void
|
||||
simple_unique_ptr_test()
|
||||
{
|
||||
auto p= Alepha::Truss::make_unique< std::string >( "Hello" );
|
||||
Alepha::Truss::unique_ptr< std::string > p2= std::move( p );
|
||||
|
||||
p= Alepha::Truss::make_unique< std::string >( "Hello" );
|
||||
|
||||
using std::swap;
|
||||
swap( p, p2 );
|
||||
}
|
||||
|
||||
static void
|
||||
unique_ptr_usage_test()
|
||||
{
|
||||
auto p= Alepha::Truss::make_unique< std::string >( "Hello" );
|
||||
|
||||
std::string &s= *p;
|
||||
std::size_t len= p->size();
|
||||
}
|
||||
|
||||
static void
|
||||
unique_ptr_capture_test()
|
||||
{
|
||||
auto p= Alepha::Truss::make_unique< std::string >( "Hello" );
|
||||
|
||||
Alepha::single_ptr< std::string > s= p.get_raw();
|
||||
|
||||
Alepha::Truss::ref_ptr< std::string > sp= p.get();
|
||||
}
|
||||
|
||||
static void
|
||||
Test0::runTests()
|
||||
{
|
||||
simple_unique_ptr_test();
|
||||
unique_ptr_usage_test();
|
||||
unique_ptr_capture_test();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user