Removed some (but not all) of the line endings I accidentally added while in VS.

Fixed a bunch of issues related to compiling unittests on VS.

Having a problem linking against boost unit tests, so can't run the tests yet.
This commit is contained in:
Shane
2013-07-18 21:42:37 -07:00
parent 66c9bc3647
commit da03627ff1
13 changed files with 3291 additions and 3271 deletions

View File

@@ -106,6 +106,16 @@ namespace cereal
void saveValue(double d) { itsWriter.Double(d); } void saveValue(double d) { itsWriter.Double(d); }
void saveValue(std::string const & s) { itsWriter.String(s.c_str(), static_cast<rapidjson::SizeType>( s.size() )); } void saveValue(std::string const & s) { itsWriter.String(s.c_str(), static_cast<rapidjson::SizeType>( s.size() )); }
void saveValue(char const * s) { itsWriter.String(s); } void saveValue(char const * s) { itsWriter.String(s); }
#ifdef _MSC_VER
template <class T> inline
typename std::enable_if<sizeof(T) == sizeof(std::uint32_t), void>::type
saveLong(T lu){ saveValue( static_cast<std::uint32_t>( lu ) ); }
template <class T> inline
typename std::enable_if<sizeof(T) != sizeof(std::uint32_t), void>::type
saveLong(T lu){ saveValue( static_cast<std::uint64_t>( lu ) ); }
void saveValue( unsigned long lu ){ saveLong( lu ); };
#endif
//! Save exotic arithmetic types as binary //! Save exotic arithmetic types as binary
template<class T> template<class T>
@@ -358,7 +368,7 @@ namespace cereal
}; };
//! Loads the size for a SizeTag //! Loads the size for a SizeTag
void loadSize(size_t & size) void loadSize(size_type & size)
{ {
size = (itsValueStack.rbegin() + 1)->value().Size(); size = (itsValueStack.rbegin() + 1)->value().Size();
} }

View File

@@ -57,7 +57,7 @@ namespace cereal
ar( _CEREAL_NVP("type", bitset_detail::type::ulong) ); ar( _CEREAL_NVP("type", bitset_detail::type::ulong) );
ar( _CEREAL_NVP("data", b) ); ar( _CEREAL_NVP("data", b) );
} }
catch( std::overflow_error const & e ) catch( std::overflow_error const & )
{ {
try try
{ {
@@ -65,7 +65,7 @@ namespace cereal
ar( _CEREAL_NVP("type", bitset_detail::type::ullong) ); ar( _CEREAL_NVP("type", bitset_detail::type::ullong) );
ar( _CEREAL_NVP("data", b) ); ar( _CEREAL_NVP("data", b) );
} }
catch( std::overflow_error const & e ) catch( std::overflow_error const & )
{ {
ar( _CEREAL_NVP("type", bitset_detail::type::string) ); ar( _CEREAL_NVP("type", bitset_detail::type::string) );
ar( _CEREAL_NVP("data", bits.to_string()) ); ar( _CEREAL_NVP("data", bits.to_string()) );

View File

@@ -52,7 +52,7 @@ namespace cereal
size_type size; size_type size;
ar( make_size_tag( size ) ); ar( make_size_tag( size ) );
deque.resize( size ); deque.resize( static_cast<size_t>( size ) );
for( auto & i : deque ) for( auto & i : deque )
ar( i ); ar( i );

View File

@@ -58,7 +58,7 @@ namespace cereal
size_type size; size_type size;
ar( make_size_tag( size ) ); ar( make_size_tag( size ) );
forward_list.resize( size ); forward_list.resize( static_cast<size_t>( size ) );
for( auto & i : forward_list ) for( auto & i : forward_list )
ar( i ); ar( i );

View File

@@ -52,7 +52,7 @@ namespace cereal
size_type size; size_type size;
ar( make_size_tag( size ) ); ar( make_size_tag( size ) );
list.resize( size ); list.resize( static_cast<size_t>( size ) );
for( auto & i : list ) for( auto & i : list )
ar( i ); ar( i );

View File

@@ -55,7 +55,7 @@ namespace cereal
ar( make_size_tag( size ) ); ar( make_size_tag( size ) );
map.clear(); map.clear();
map.reserve( size ); map.reserve( static_cast<std::size_t>( size ) );
for( size_type i = 0; i < size; ++i ) for( size_type i = 0; i < size; ++i )
{ {

View File

@@ -55,7 +55,7 @@ namespace cereal
ar( make_size_tag( size ) ); ar( make_size_tag( size ) );
set.clear(); set.clear();
set.reserve( size ); set.reserve( static_cast<std::size_t>( size ) );
for( size_type i = 0; i < size; ++i ) for( size_type i = 0; i < size; ++i )
{ {

View File

@@ -54,8 +54,8 @@ namespace cereal
size_type vectorSize; size_type vectorSize;
ar( make_size_tag( vectorSize ) ); ar( make_size_tag( vectorSize ) );
vector.resize( vectorSize ); vector.resize( static_cast<std::size_t>( vectorSize ) );
ar( binary_data( vector.data(), vectorSize * sizeof(T) ) ); ar( binary_data( vector.data(), static_cast<std::size_t>( vectorSize ) * sizeof(T) ) );
} }
//! Serialization for non-arithmetic (and bool) vector types //! Serialization for non-arithmetic (and bool) vector types

View File

@@ -24,6 +24,9 @@
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifdef _MSC_VER
#define BOOST_ALL_NO_LIB
#endif // _MSC_VER
#include <cereal/types/memory.hpp> #include <cereal/types/memory.hpp>
#include <cereal/types/array.hpp> #include <cereal/types/array.hpp>
#include <cereal/types/vector.hpp> #include <cereal/types/vector.hpp>
@@ -173,17 +176,22 @@ random_value(std::mt19937 & gen)
{ return std::uniform_real_distribution<T>(-10000.0, 10000.0)(gen); } { return std::uniform_real_distribution<T>(-10000.0, 10000.0)(gen); }
template<class T> template<class T>
typename std::enable_if<std::is_integral<T>::value, T>::type typename std::enable_if<std::is_integral<T>::value && sizeof(T) != sizeof(char), T>::type
random_value(std::mt19937 & gen) random_value(std::mt19937 & gen)
{ return std::uniform_int_distribution<T>(std::numeric_limits<T>::lowest(), std::numeric_limits<T>::max())(gen); } { return std::uniform_int_distribution<T>(std::numeric_limits<T>::lowest(), std::numeric_limits<T>::max())(gen); }
template<class T>
typename std::enable_if<std::is_integral<T>::value && sizeof(T) == sizeof(char), T>::type
random_value(std::mt19937 & gen)
{ return static_cast<T>( std::uniform_int_distribution<uint64_t>(std::numeric_limits<T>::lowest(), std::numeric_limits<T>::max())(gen) ); }
template<class T> template<class T>
typename std::enable_if<std::is_same<T, std::string>::value, std::string>::type typename std::enable_if<std::is_same<T, std::string>::value, std::string>::type
random_value(std::mt19937 & gen) random_value(std::mt19937 & gen)
{ {
std::string s(std::uniform_int_distribution<int>(3, 30)(gen), ' '); std::string s(std::uniform_int_distribution<int>(3, 30)(gen), ' ');
for(char & c : s) for(char & c : s)
c = std::uniform_int_distribution<char>(' ', '~')(gen); c = static_cast<char>( std::uniform_int_distribution<int>( '~', '~' )(gen) );
return s; return s;
} }
@@ -192,7 +200,7 @@ std::basic_string<C> random_basic_string(std::mt19937 & gen)
{ {
std::basic_string<C> s(std::uniform_int_distribution<int>(3, 30)(gen), ' '); std::basic_string<C> s(std::uniform_int_distribution<int>(3, 30)(gen), ' ');
for(C & c : s) for(C & c : s)
c = std::uniform_int_distribution<C>(' ', '~')(gen); c = static_cast<C>( std::uniform_int_distribution<int>( '~', '~' )(gen) );
return s; return s;
} }
@@ -201,7 +209,7 @@ std::string random_binary_string(std::mt19937 & gen)
{ {
std::string s(N, ' '); std::string s(N, ' ');
for(auto & c : s ) for(auto & c : s )
c = std::uniform_int_distribution<char>('0', '1')(gen); c = static_cast<char>( std::uniform_int_distribution<int>( '0', '1' )(gen) );
return s; return s;
} }
@@ -279,7 +287,7 @@ void test_pod()
BOOST_CHECK_EQUAL(i_int32 , o_int32); BOOST_CHECK_EQUAL(i_int32 , o_int32);
BOOST_CHECK_EQUAL(i_uint64 , o_uint64); BOOST_CHECK_EQUAL(i_uint64 , o_uint64);
BOOST_CHECK_EQUAL(i_int64 , o_int64); BOOST_CHECK_EQUAL(i_int64 , o_int64);
BOOST_CHECK_CLOSE(i_float , o_float, 1e-5); BOOST_CHECK_CLOSE(i_float , o_float, (float)1e-5);
BOOST_CHECK_CLOSE(i_double , o_double, 1e-5); BOOST_CHECK_CLOSE(i_double , o_double, 1e-5);
} }
} }
@@ -381,15 +389,15 @@ void test_array()
std::array<StructInternalSplit, 100> o_isplarray; std::array<StructInternalSplit, 100> o_isplarray;
for(auto & elem : o_isplarray) for(auto & elem : o_isplarray)
elem = StructInternalSplit{ random_value<int>(gen), random_value<int>(gen) }; elem = StructInternalSplit( random_value<int>(gen), random_value<int>(gen) );
std::array<StructExternalSerialize, 100> o_eserarray; std::array<StructExternalSerialize, 100> o_eserarray;
for(auto & elem : o_eserarray) for(auto & elem : o_eserarray)
elem = StructExternalSerialize{ random_value<int>(gen), random_value<int>(gen) }; elem = StructExternalSerialize( random_value<int>(gen), random_value<int>(gen) );
std::array<StructExternalSplit, 100> o_esplarray; std::array<StructExternalSplit, 100> o_esplarray;
for(auto & elem : o_esplarray) for(auto & elem : o_esplarray)
elem = StructExternalSplit{ random_value<int>(gen), random_value<int>(gen) }; elem = StructExternalSplit( random_value<int>(gen), random_value<int>(gen) );
std::ostringstream os; std::ostringstream os;
{ {
@@ -462,19 +470,19 @@ void test_deque()
std::deque<StructInternalSerialize> o_iserdeque(100); std::deque<StructInternalSerialize> o_iserdeque(100);
for(auto & elem : o_iserdeque) for(auto & elem : o_iserdeque)
elem = { random_value<int>(gen), random_value<int>(gen) }; elem = StructInternalSerialize( random_value<int>(gen), random_value<int>(gen) );
std::deque<StructInternalSplit> o_ispldeque(100); std::deque<StructInternalSplit> o_ispldeque(100);
for(auto & elem : o_ispldeque) for(auto & elem : o_ispldeque)
elem = { random_value<int>(gen), random_value<int>(gen) }; elem = StructInternalSplit( random_value<int>(gen), random_value<int>(gen) );
std::deque<StructExternalSerialize> o_eserdeque(100); std::deque<StructExternalSerialize> o_eserdeque(100);
for(auto & elem : o_eserdeque) for(auto & elem : o_eserdeque)
elem = { random_value<int>(gen), random_value<int>(gen) }; elem = StructExternalSerialize( random_value<int>(gen), random_value<int>(gen) );
std::deque<StructExternalSplit> o_espldeque(100); std::deque<StructExternalSplit> o_espldeque(100);
for(auto & elem : o_espldeque) for(auto & elem : o_espldeque)
elem = { random_value<int>(gen), random_value<int>(gen) }; elem = StructExternalSplit( random_value<int>(gen), random_value<int>(gen) );
std::ostringstream os; std::ostringstream os;
{ {
@@ -553,19 +561,19 @@ void test_forward_list()
std::forward_list<StructInternalSerialize> o_iserforward_list(100); std::forward_list<StructInternalSerialize> o_iserforward_list(100);
for(auto & elem : o_iserforward_list) for(auto & elem : o_iserforward_list)
elem = { random_value<int>(gen), random_value<int>(gen) }; elem = StructInternalSerialize( random_value<int>(gen), random_value<int>(gen) );
std::forward_list<StructInternalSplit> o_isplforward_list(100); std::forward_list<StructInternalSplit> o_isplforward_list(100);
for(auto & elem : o_isplforward_list) for(auto & elem : o_isplforward_list)
elem = { random_value<int>(gen), random_value<int>(gen) }; elem = StructInternalSplit( random_value<int>(gen), random_value<int>(gen) );
std::forward_list<StructExternalSerialize> o_eserforward_list(100); std::forward_list<StructExternalSerialize> o_eserforward_list(100);
for(auto & elem : o_eserforward_list) for(auto & elem : o_eserforward_list)
elem = { random_value<int>(gen), random_value<int>(gen) }; elem = StructExternalSerialize( random_value<int>(gen), random_value<int>(gen) );
std::forward_list<StructExternalSplit> o_esplforward_list(100); std::forward_list<StructExternalSplit> o_esplforward_list(100);
for(auto & elem : o_esplforward_list) for(auto & elem : o_esplforward_list)
elem = { random_value<int>(gen), random_value<int>(gen) }; elem = StructExternalSplit( random_value<int>(gen), random_value<int>(gen) );
std::ostringstream os; std::ostringstream os;
{ {
@@ -638,19 +646,19 @@ void test_list()
std::list<StructInternalSerialize> o_iserlist(100); std::list<StructInternalSerialize> o_iserlist(100);
for(auto & elem : o_iserlist) for(auto & elem : o_iserlist)
elem = { random_value<int>(gen), random_value<int>(gen) }; elem = StructInternalSerialize( random_value<int>(gen), random_value<int>(gen) );
std::list<StructInternalSplit> o_ispllist(100); std::list<StructInternalSplit> o_ispllist(100);
for(auto & elem : o_ispllist) for(auto & elem : o_ispllist)
elem = { random_value<int>(gen), random_value<int>(gen) }; elem = StructInternalSplit( random_value<int>(gen), random_value<int>(gen) );
std::list<StructExternalSerialize> o_eserlist(100); std::list<StructExternalSerialize> o_eserlist(100);
for(auto & elem : o_eserlist) for(auto & elem : o_eserlist)
elem = { random_value<int>(gen), random_value<int>(gen) }; elem = StructExternalSerialize( random_value<int>(gen), random_value<int>(gen) );
std::list<StructExternalSplit> o_espllist(100); std::list<StructExternalSplit> o_espllist(100);
for(auto & elem : o_espllist) for(auto & elem : o_espllist)
elem = { random_value<int>(gen), random_value<int>(gen) }; elem = StructExternalSplit( random_value<int>(gen), random_value<int>(gen) );
std::ostringstream os; std::ostringstream os;
{ {
@@ -2101,19 +2109,19 @@ void test_vector()
std::vector<StructInternalSerialize> o_iservector(100); std::vector<StructInternalSerialize> o_iservector(100);
for(auto & elem : o_iservector) for(auto & elem : o_iservector)
elem = { random_value<int>(gen), random_value<int>(gen) }; elem = StructInternalSerialize( random_value<int>(gen), random_value<int>(gen) );
std::vector<StructInternalSplit> o_isplvector(100); std::vector<StructInternalSplit> o_isplvector(100);
for(auto & elem : o_isplvector) for(auto & elem : o_isplvector)
elem = { random_value<int>(gen), random_value<int>(gen) }; elem = StructInternalSplit( random_value<int>(gen), random_value<int>(gen) );
std::vector<StructExternalSerialize> o_eservector(100); std::vector<StructExternalSerialize> o_eservector(100);
for(auto & elem : o_eservector) for(auto & elem : o_eservector)
elem = { random_value<int>(gen), random_value<int>(gen) }; elem = StructExternalSerialize( random_value<int>(gen), random_value<int>(gen) );
std::vector<StructExternalSplit> o_esplvector(100); std::vector<StructExternalSplit> o_esplvector(100);
for(auto & elem : o_esplvector) for(auto & elem : o_esplvector)
elem = { random_value<int>(gen), random_value<int>(gen) }; elem = StructExternalSplit( random_value<int>(gen), random_value<int>(gen) );
std::ostringstream os; std::ostringstream os;
{ {
@@ -2915,7 +2923,7 @@ BOOST_AUTO_TEST_CASE( portable_binary_archive )
BOOST_CHECK_EQUAL(i_int32 , o_int32); BOOST_CHECK_EQUAL(i_int32 , o_int32);
BOOST_CHECK_EQUAL(i_uint64 , o_uint64); BOOST_CHECK_EQUAL(i_uint64 , o_uint64);
BOOST_CHECK_EQUAL(i_int64 , o_int64); BOOST_CHECK_EQUAL(i_int64 , o_int64);
BOOST_CHECK_CLOSE(i_float , o_float, 1e-5); BOOST_CHECK_CLOSE(i_float , o_float, (float)1e-5);
BOOST_CHECK_CLOSE(i_double , o_double, 1e-5); BOOST_CHECK_CLOSE(i_double , o_double, 1e-5);
} }
} }

View File

@@ -66,7 +66,7 @@
</ImportGroup> </ImportGroup>
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(SolutionDir)\..\include;C:\Boost\include\boost-1_54;$(IncludePath)</IncludePath> <IncludePath>$(SolutionDir)\..\include;C:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
<LibraryPath>C:\Boost\lib;$(LibraryPath)</LibraryPath> <LibraryPath>C:\Boost\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@@ -74,7 +74,7 @@
<LibraryPath>C:\Boost\lib;$(LibraryPath)</LibraryPath> <LibraryPath>C:\Boost\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(SolutionDir)\..\include;C:\Boost\include\boost-1_54;$(IncludePath)</IncludePath> <IncludePath>$(SolutionDir)\..\include;C:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
<LibraryPath>C:\Boost\lib;$(LibraryPath)</LibraryPath> <LibraryPath>C:\Boost\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -89,6 +89,7 @@
</ClCompile> </ClCompile>
<Link> <Link>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libboost_unit_test_framework-vc120-mt-gd-1_55.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@@ -113,6 +114,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>libboost_unit_test_framework-vc120-mt-1_55.lib;libboost_test_exec_monitor-vc120-mt-1_55.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">