unit test type_erased.cpp corrected mix of value types under test.

This commit is contained in:
Neil Groves
2014-02-21 17:50:28 +00:00
parent b795de8310
commit 96054b0b48

View File

@ -14,6 +14,7 @@
#include <boost/range/algorithm/fill.hpp> #include <boost/range/algorithm/fill.hpp>
#include <boost/assign.hpp> #include <boost/assign.hpp>
#include <boost/array.hpp> #include <boost/array.hpp>
#include <boost/cstdint.hpp>
#include <algorithm> #include <algorithm>
#include <list> #include <list>
@ -30,12 +31,12 @@ namespace boost_range_adaptor_type_erased_test
{ {
} }
MockType(int x) MockType(boost::int32_t x)
: m_x(x) : m_x(x)
{ {
} }
int get() const { return m_x; } boost::int32_t get() const { return m_x; }
inline bool operator==(const MockType& other) const inline bool operator==(const MockType& other) const
{ {
@ -48,7 +49,15 @@ namespace boost_range_adaptor_type_erased_test
} }
private: private:
int m_x; boost::int32_t m_x;
};
class MockType2 : public MockType
{
public:
MockType2() {}
MockType2(boost::int32_t x) : MockType(x) { }
MockType2(const MockType& other) : MockType(other) { }
}; };
inline std::ostream& operator<<(std::ostream& out, const MockType& obj) inline std::ostream& operator<<(std::ostream& out, const MockType& obj)
@ -418,15 +427,12 @@ namespace boost_range_adaptor_type_erased_test
template<class Traversal> template<class Traversal>
void test_type_erased_mix_values_driver() void test_type_erased_mix_values_driver()
{ {
test_type_erased_mix_values_impl< Traversal, int, char, const int&, short, const int& >(); test_type_erased_mix_values_impl<
test_type_erased_mix_values_impl< Traversal, int, int*, const int&, char, const int& >(); Traversal,
test_type_erased_mix_values_impl< Traversal, MockType, char, const MockType&, short, const MockType& >(); MockType,
MockType2, const MockType&,
// In fact value type should have no effect in the eligibility MockType, const MockType&
// for conversion, hence we should be able to convert it >();
// completely backwards!
test_type_erased_mix_values_impl< Traversal, int, short, const int&, char, const int& >();
test_type_erased_mix_values_impl< Traversal, int, char, const int&, int*, const int& >();
} }
void test_type_erased_mix_values() void test_type_erased_mix_values()