|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r72876 - in sandbox/coerce: boost/coerce libs/coerce/test
From: vexocide_at_[hidden]
Date: 2011-07-03 12:23:07
Author: vexocide
Date: 2011-07-03 12:23:06 EDT (Sun, 03 Jul 2011)
New Revision: 72876
URL: http://svn.boost.org/trac/boost/changeset/72876
Log:
Added reserve tests
Added:
sandbox/coerce/libs/coerce/test/reserve.cpp (contents, props changed)
Text files modified:
sandbox/coerce/boost/coerce/reserve.hpp | 3 +--
sandbox/coerce/libs/coerce/test/Jamfile.v2 | 3 +++
2 files changed, 4 insertions(+), 2 deletions(-)
Modified: sandbox/coerce/boost/coerce/reserve.hpp
==============================================================================
--- sandbox/coerce/boost/coerce/reserve.hpp (original)
+++ sandbox/coerce/boost/coerce/reserve.hpp 2011-07-03 12:23:06 EDT (Sun, 03 Jul 2011)
@@ -23,8 +23,7 @@
template <typename T>
struct reserve_size_impl {
- BOOST_STATIC_CONSTANT(std::size_t, value =
- 3 * sizeof(T) + 1);
+ BOOST_STATIC_CONSTANT(std::size_t, value = 0);
};
template <>
Modified: sandbox/coerce/libs/coerce/test/Jamfile.v2
==============================================================================
--- sandbox/coerce/libs/coerce/test/Jamfile.v2 (original)
+++ sandbox/coerce/libs/coerce/test/Jamfile.v2 2011-07-03 12:23:06 EDT (Sun, 03 Jul 2011)
@@ -16,5 +16,8 @@
unit-test karma :
karma.cpp ;
+unit-test reserve :
+ reserve.cpp ;
+
unit-test qi :
qi.cpp ;
Added: sandbox/coerce/libs/coerce/test/reserve.cpp
==============================================================================
--- (empty file)
+++ sandbox/coerce/libs/coerce/test/reserve.cpp 2011-07-03 12:23:06 EDT (Sun, 03 Jul 2011)
@@ -0,0 +1,51 @@
+// Copyright Jeroen Habraken 2010 - 2011.
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file ../../../LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#define BOOST_TEST_MODULE reserve
+
+#include <boost/coerce.hpp>
+#include <boost/optional.hpp>
+#include <boost/test/unit_test.hpp>
+
+#include <string>
+#include <vector>
+
+BOOST_AUTO_TEST_CASE(reserve_size) {
+ using boost::coerce::traits::reserve_size;
+
+ BOOST_CHECK_GT(reserve_size<char>::call('\0'), 0u);
+ BOOST_CHECK_GT(reserve_size<wchar_t>::call(L'\0'), 0u);
+ short const test_short = 0;
+ BOOST_CHECK_GT(reserve_size<short>::call(test_short), 0u);
+ BOOST_CHECK_GT(reserve_size<int>::call(0), 0u);
+ BOOST_CHECK_GT(reserve_size<long>::call(0l), 0u);
+ unsigned short const test_unsigned_short = 0u;
+ BOOST_CHECK_GT(reserve_size<unsigned short>::call(
+ test_unsigned_short), 0u);
+ BOOST_CHECK_GT(reserve_size<unsigned int>::call(0u), 0u);
+ BOOST_CHECK_GT(reserve_size<unsigned long>::call(0ul), 0u);
+ BOOST_CHECK_GT(reserve_size<float>::call(0.0f), 0u);
+ BOOST_CHECK_GT(reserve_size<double>::call(0.0), 0u);
+ BOOST_CHECK_GT(reserve_size<long double>::call(0.0l), 0u);
+ BOOST_CHECK_GT(reserve_size<bool>::call(false), 0u);
+
+ BOOST_CHECK_GT(reserve_size<boost::optional<char> >::call(
+ boost::optional<char>('\0')), 0u);
+}
+
+BOOST_AUTO_TEST_CASE(has_reserve) {
+ using boost::coerce::detail::has_reserve;
+
+ BOOST_CHECK(!has_reserve<void>::type());
+
+ BOOST_CHECK(has_reserve<std::string>::type());
+ BOOST_CHECK(has_reserve<std::wstring>::type());
+
+ BOOST_CHECK(has_reserve<std::vector<char> >::type());
+ BOOST_CHECK(has_reserve<std::vector<wchar_t> >::type());
+}
+
+// TODO, call_reserve
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