|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r65302 - sandbox/chrono/libs/type_traits_ext/test
From: vicente.botet_at_[hidden]
Date: 2010-09-05 13:34:24
Author: viboes
Date: 2010-09-05 13:34:21 EDT (Sun, 05 Sep 2010)
New Revision: 65302
URL: http://svn.boost.org/trac/boost/changeset/65302
Log:
Add test for TypeTraits.Ext
Added:
sandbox/chrono/libs/type_traits_ext/test/Jamfile.v2 (contents, props changed)
sandbox/chrono/libs/type_traits_ext/test/add_rvalue_reference_test.cpp (contents, props changed)
sandbox/chrono/libs/type_traits_ext/test/common_type_fails.cpp (contents, props changed)
sandbox/chrono/libs/type_traits_ext/test/common_type_test.cpp (contents, props changed)
Added: sandbox/chrono/libs/type_traits_ext/test/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/type_traits_ext/test/Jamfile.v2 2010-09-05 13:34:21 EDT (Sun, 05 Sep 2010)
@@ -0,0 +1,47 @@
+# Boost Chrono Library test Jamfile
+
+# Copyright Beman Dawes 2003, 2006, 2008
+
+# Distributed under the Boost Software License, Version 1.0.
+# See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt
+
+# See library home page at http://www.boost.org/libs/chrono
+
+# uncomment one if the above lines if you build outside the Boost release
+#local BOOST_ROOT = /boost_1_41_0 ;
+#local BOOST_ROOT = c:/cygwin/boost_1_41_0 ;
+
+if ! $(BOOST_ROOT)
+{
+ BOOST_ROOT = [ modules.peek : BOOST_ROOT ] ;
+}
+
+project
+ : requirements
+ <os>LINUX:<threading>multi
+ # uncomment the line above if you build outside the Boost release
+ #<include>$(BOOST_ROOT)
+ # uncomment the line above if you build outside the Boost release
+ #<include>../../..
+ <toolset>msvc:<asynch-exceptions>on
+ <define>BOOST_ENABLE_WARNINGS
+ <warnings>all
+ <toolset>gcc:<cxxflags>-Wextra
+ <toolset>gcc:<cxxflags>-Wno-long-long
+ <toolset>gcc-mingw-4.5.0:<cxxflags>-Wno-missing-field-initializers
+ <toolset>gcc-mingw-4.5.0:<cxxflags>-fdiagnostics-show-option
+ <toolset>msvc:<cxxflags>/wd4127
+ ;
+
+ test-suite "common_type"
+ :
+ [ run common_type_test.cpp ]
+ [ compile-fail common_type_fails.cpp ]
+ ;
+
+ test-suite "add_rvalue_reference"
+ :
+ [ run add_rvalue_reference_test.cpp ]
+ ;
+
+
Added: sandbox/chrono/libs/type_traits_ext/test/add_rvalue_reference_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/type_traits_ext/test/add_rvalue_reference_test.cpp 2010-09-05 13:34:21 EDT (Sun, 05 Sep 2010)
@@ -0,0 +1,80 @@
+
+// (C) Copyright John Maddock 2000.
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.tt.org/LICENSE_1_0.txt)
+
+#include "../../type_traits/test/test.hpp"
+#include "../../type_traits/test/check_type.hpp"
+#ifdef TEST_STD
+# include <type_traits>
+#else
+# include <boost/type_traits/add_rvalue_reference.hpp>
+#endif
+
+#ifdef BOOST_NO_RVALUE_REFERENCES
+
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_1, ::tt::add_rvalue_reference, const, const)
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_2, ::tt::add_rvalue_reference, volatile, volatile)
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_3, ::tt::add_rvalue_reference, *, *)
+//~ BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_4, ::tt::add_rvalue_reference, &)
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_5, ::tt::add_rvalue_reference, const &, const&)
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_6, ::tt::add_rvalue_reference, &, &)
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_7, ::tt::add_rvalue_reference, *volatile, *volatile)
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_8, ::tt::add_rvalue_reference, const [2], const [2])
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_9, ::tt::add_rvalue_reference, const &, const&)
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_10, ::tt::add_rvalue_reference, const*, const*)
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_11, ::tt::add_rvalue_reference, volatile*, volatile*)
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_12, ::tt::add_rvalue_reference, const[2][3], const [2][3])
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_13, ::tt::add_rvalue_reference, (&)[2], (&)[2])
+#else
+
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_1, ::tt::add_rvalue_reference, const, const&&)
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_2, ::tt::add_rvalue_reference, volatile, volatile&&)
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_3, ::tt::add_rvalue_reference, *, *)
+//~ BOOST_DECL_TRANSFORM_TEST2(add_rvalue_reference_test_4, ::tt::add_rvalue_reference, &)
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_5, ::tt::add_rvalue_reference, const &, const&)
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_6, ::tt::add_rvalue_reference, &, &)
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_7, ::tt::add_rvalue_reference, *volatile, *volatile)
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_8, ::tt::add_rvalue_reference, const [2], const (&&) [2])
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_9, ::tt::add_rvalue_reference, const &, const&)
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_10, ::tt::add_rvalue_reference, const*, const*)
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_11, ::tt::add_rvalue_reference, volatile*, volatile*)
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_12, ::tt::add_rvalue_reference, const[2][3], const (&&) [2][3])
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_13, ::tt::add_rvalue_reference, (&)[2], (&)[2])
+
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_5a, ::tt::add_rvalue_reference, const &&, const&&)
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_6a, ::tt::add_rvalue_reference, &&, &&)
+BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_13a, ::tt::add_rvalue_reference, (&&)[2], (&&)[2])
+#endif
+
+TT_TEST_BEGIN(add_rvalue_reference)
+
+ add_rvalue_reference_test_1();
+ add_rvalue_reference_test_2();
+ add_rvalue_reference_test_3();
+ //~ add_rvalue_reference_test_4();
+ add_rvalue_reference_test_5();
+ add_rvalue_reference_test_6();
+ add_rvalue_reference_test_7();
+ add_rvalue_reference_test_8();
+ add_rvalue_reference_test_9();
+ add_rvalue_reference_test_10();
+ add_rvalue_reference_test_11();
+ add_rvalue_reference_test_12();
+ add_rvalue_reference_test_13();
+#ifndef BOOST_NO_RVALUE_REFERENCES
+ add_rvalue_reference_test_5a();
+ add_rvalue_reference_test_6a();
+ add_rvalue_reference_test_13a();
+#endif
+
+TT_TEST_END
+
+
+
+
+
+
+
+
Added: sandbox/chrono/libs/type_traits_ext/test/common_type_fails.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/type_traits_ext/test/common_type_fails.cpp 2010-09-05 13:34:21 EDT (Sun, 05 Sep 2010)
@@ -0,0 +1,37 @@
+// common_type_test.cpp ----------------------------------------------------//
+
+// Copyright 2010 Beman Dawes
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#define _CRT_SECURE_NO_WARNINGS // disable VC++ foolishness
+
+#define STD2
+#ifndef STD
+#include <boost/type_traits/common_type.hpp>
+#else
+#include <type_traits>
+#endif
+#include <iostream>
+
+
+#include <boost/test/minimal.hpp>
+
+struct C1 {
+ //~ private:
+ //~ C1();
+};
+
+struct C2 {};
+
+
+
+#ifndef STD
+typedef boost::common_type<C1, C2>::type AC;
+#else
+typedef std::common_type<C1, C2>::type AC;
+#endif
+//~ AC* ac;
+
+
\ No newline at end of file
Added: sandbox/chrono/libs/type_traits_ext/test/common_type_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/type_traits_ext/test/common_type_test.cpp 2010-09-05 13:34:21 EDT (Sun, 05 Sep 2010)
@@ -0,0 +1,99 @@
+// common_type_test.cpp ----------------------------------------------------//
+
+// Copyright 2010 Beman Dawes
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#define _CRT_SECURE_NO_WARNINGS // disable VC++ foolishness
+
+#include <boost/type_traits/common_type.hpp>
+#include <iostream>
+
+#include <boost/test/minimal.hpp>
+
+struct C1 {};
+
+struct C2 {};
+
+
+struct C3 : C2 {};
+struct C1C2 {
+ C1C2() {}
+ C1C2(C1 const&) {}
+ C1C2(C2 const&) {}
+ C1C2& operator=(C1C2 const&) {
+ return *this;
+ }
+};
+
+template <typename C, typename A>
+void f2(typename boost::common_type<A, C>::type const& ) {}
+
+template <typename C, typename A, typename B>
+void f3(typename boost::common_type<C, A, B>::type const& ) {}
+
+template <typename C, typename A>
+void assignation_2() {
+typedef typename boost::common_type<A, C>::type AC;
+ A a;
+ C c;
+ AC ac;
+ ac=a;
+ ac=c;
+
+ f2<C, A>(a);
+ f2<C, A>(c);
+
+}
+
+template <typename C, typename A, typename B>
+void assignation_3() {
+typedef typename boost::common_type<C, A, B>::type ABC;
+ A a;
+ B b;
+ C c;
+ ABC abc;
+
+ abc=a;
+ abc=b;
+ abc=c;
+
+ f3<C, A, B>(a);
+ f3<C, A, B>(b);
+ f3<C, A, B>(c);
+}
+
+C1C2 c1c2;
+C1 c1;
+
+int f(C1C2 ) { return 1;}
+int f(C1 ) { return 2;}
+template <typename OSTREAM>
+OSTREAM& operator<<(OSTREAM& os, C1 const&) {return os;}
+
+C1C2& declval_C1C2() {return c1c2;}
+C1& declval_C1(){return c1;}
+bool declval_bool(){return true;}
+
+int test_main( int /*argc*/, char * /*argv*/[] )
+{
+ assignation_2<C1C2, C1>();
+ typedef boost::common_type<C1C2&, C1&>::type T1; // fails if BOOST_COMMON_TYPE_DONT_USE_TYPEOF
+ //~ std::cout << f(declval_bool()?declval_C1C2():declval_C1()) << std::endl;
+ typedef boost::common_type<C3*, C2*>::type T2;
+ typedef boost::common_type<int*, int const*>::type T3;
+ typedef boost::common_type<int volatile*, int const*>::type T4; // fails if BOOST_COMMON_TYPE_DONT_USE_TYPEOF
+ typedef boost::common_type<int*, int volatile*>::type T5;
+ //~ typedef boost::common_type<short volatile*, int const*>::type T5; // fails
+
+ assignation_2<C1, C1C2>();
+ assignation_2<C1C2, C2>();
+ assignation_2<C2, C1C2>();
+ assignation_3<C1, C1C2, C2>();
+ assignation_3<C1C2, C1, C2>();
+ assignation_3<C2, C1C2, C1>();
+ assignation_3<C1C2, C2, C1>();
+ //~ assignation_3<C1, C2, C1C2>(); // fails because the common type is the third
+ return 0;
+}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk