31
|
1 |
//
|
|
2 |
// pointer_to_other_test.cpp - a test for boost/pointer_to_other.hpp
|
|
3 |
//
|
|
4 |
// Copyright (c) 2005 Peter Dimov
|
|
5 |
//
|
|
6 |
// Distributed under the Boost Software License, Version 1.0. (See
|
|
7 |
// accompanying file LICENSE_1_0.txt or copy at
|
|
8 |
// http://www.boost.org/LICENSE_1_0.txt)
|
|
9 |
//
|
|
10 |
/*
|
|
11 |
* © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
|
|
12 |
*/
|
|
13 |
|
|
14 |
#include <boost/pointer_to_other.hpp>
|
|
15 |
|
|
16 |
#include <boost/shared_ptr.hpp>
|
|
17 |
#include <boost/shared_array.hpp>
|
|
18 |
#include <boost/scoped_ptr.hpp>
|
|
19 |
#include <boost/scoped_array.hpp>
|
|
20 |
#include <boost/intrusive_ptr.hpp>
|
|
21 |
|
|
22 |
#include <memory>
|
|
23 |
|
|
24 |
#ifdef __SYMBIAN32__
|
|
25 |
#include "std_log_result.h"
|
|
26 |
#define LOG_FILENAME_LINE __FILE__, __LINE__
|
|
27 |
#endif
|
|
28 |
|
|
29 |
template<class T, class U> void assert_same_type( T** pt = 0, U** pu = 0 )
|
|
30 |
{
|
|
31 |
pt = pu;
|
|
32 |
}
|
|
33 |
|
|
34 |
struct X;
|
|
35 |
struct Y;
|
|
36 |
|
|
37 |
int main()
|
|
38 |
{
|
|
39 |
std_log(LOG_FILENAME_LINE,"[Test Case for pointer_to_other_test]");
|
|
40 |
// shared_ptr
|
|
41 |
|
|
42 |
#ifdef __ARMCC__
|
|
43 |
#pragma diag_suppress 550
|
|
44 |
#endif
|
|
45 |
assert_same_type< boost::pointer_to_other< boost::shared_ptr<X>, Y >::type, boost::shared_ptr<Y> >();
|
|
46 |
assert_same_type< boost::pointer_to_other< boost::shared_ptr<X>, void >::type, boost::shared_ptr<void> >();
|
|
47 |
assert_same_type< boost::pointer_to_other< boost::shared_ptr<void>, Y >::type, boost::shared_ptr<Y> >();
|
|
48 |
|
|
49 |
// shared_array
|
|
50 |
|
|
51 |
assert_same_type< boost::pointer_to_other< boost::shared_array<X>, Y >::type, boost::shared_array<Y> >();
|
|
52 |
assert_same_type< boost::pointer_to_other< boost::shared_array<X>, void >::type, boost::shared_array<void> >();
|
|
53 |
assert_same_type< boost::pointer_to_other< boost::shared_array<void>, Y >::type, boost::shared_array<Y> >();
|
|
54 |
|
|
55 |
// scoped_ptr
|
|
56 |
|
|
57 |
assert_same_type< boost::pointer_to_other< boost::scoped_ptr<X>, Y >::type, boost::scoped_ptr<Y> >();
|
|
58 |
assert_same_type< boost::pointer_to_other< boost::scoped_ptr<X>, void >::type, boost::scoped_ptr<void> >();
|
|
59 |
assert_same_type< boost::pointer_to_other< boost::scoped_ptr<void>, Y >::type, boost::scoped_ptr<Y> >();
|
|
60 |
|
|
61 |
// scoped_array
|
|
62 |
|
|
63 |
assert_same_type< boost::pointer_to_other< boost::scoped_array<X>, Y >::type, boost::scoped_array<Y> >();
|
|
64 |
assert_same_type< boost::pointer_to_other< boost::scoped_array<X>, void >::type, boost::scoped_array<void> >();
|
|
65 |
assert_same_type< boost::pointer_to_other< boost::scoped_array<void>, Y >::type, boost::scoped_array<Y> >();
|
|
66 |
|
|
67 |
// intrusive_ptr
|
|
68 |
|
|
69 |
assert_same_type< boost::pointer_to_other< boost::intrusive_ptr<X>, Y >::type, boost::intrusive_ptr<Y> >();
|
|
70 |
assert_same_type< boost::pointer_to_other< boost::intrusive_ptr<X>, void >::type, boost::intrusive_ptr<void> >();
|
|
71 |
assert_same_type< boost::pointer_to_other< boost::intrusive_ptr<void>, Y >::type, boost::intrusive_ptr<Y> >();
|
|
72 |
|
|
73 |
// auto_ptr
|
|
74 |
|
|
75 |
assert_same_type< boost::pointer_to_other< std::auto_ptr<X>, Y >::type, std::auto_ptr<Y> >();
|
|
76 |
assert_same_type< boost::pointer_to_other< std::auto_ptr<X>, void >::type, std::auto_ptr<void> >();
|
|
77 |
assert_same_type< boost::pointer_to_other< std::auto_ptr<void>, Y >::type, std::auto_ptr<Y> >();
|
|
78 |
|
|
79 |
// raw pointer
|
|
80 |
|
|
81 |
assert_same_type< boost::pointer_to_other< X *, Y >::type, Y * >();
|
|
82 |
assert_same_type< boost::pointer_to_other< X *, void >::type, void * >();
|
|
83 |
assert_same_type< boost::pointer_to_other< void *, Y >::type, Y * >();
|
|
84 |
|
|
85 |
|
|
86 |
#ifdef __SYMBIAN32__
|
|
87 |
|
|
88 |
std_log(LOG_FILENAME_LINE,"Result : Passed");
|
|
89 |
|
|
90 |
std_log(LOG_FILENAME_LINE,"[End Test Case ]");
|
|
91 |
#endif
|
|
92 |
testResultXml("pointer_to_other_test");
|
|
93 |
close_log_file();
|
|
94 |
return 0;
|
|
95 |
}
|