mirror of
https://github.com/boostorg/endian.git
synced 2025-08-02 14:04:29 +02:00
Add endian_in_union_test, endian_operations_test. Disable cover operations for now.
git-svn-id: http://svn.boost.org/svn/boost/sandbox/endian@46012 b8fc166d-592f-0410-95f2-cb63ce0dd405
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
// Boost endian.hpp header file (proposed) ----------------------------------//
|
// Boost endian.hpp header file ---------------------------------------------//
|
||||||
|
|
||||||
// (C) Copyright Darin Adler 2000
|
// (C) Copyright Darin Adler 2000
|
||||||
// (C) Copyright Beman Dawes 2006
|
// (C) Copyright Beman Dawes 2006
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
#define BOOST_ENDIAN_HPP
|
#define BOOST_ENDIAN_HPP
|
||||||
|
|
||||||
#include <boost/detail/endian.hpp>
|
#include <boost/detail/endian.hpp>
|
||||||
#include <boost/integer/cover_operators.hpp>
|
//#include <boost/integer/cover_operators.hpp>
|
||||||
#include <boost/type_traits/is_signed.hpp>
|
#include <boost/type_traits/is_signed.hpp>
|
||||||
#include <boost/cstdint.hpp>
|
#include <boost/cstdint.hpp>
|
||||||
#include <boost/static_assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
@@ -44,6 +44,11 @@
|
|||||||
# define BOOST_ENDIAN_DEFAULTED {} // C++03
|
# define BOOST_ENDIAN_DEFAULTED {} // C++03
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# if defined(BOOST_NO_DEFAULTED_FUNCTIONS) && defined(BOOST_ENDIANS_IN_UNIONS)
|
||||||
|
# define BOOST_ENDIAN_NO_CTORS
|
||||||
|
# endif
|
||||||
|
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
@@ -155,12 +160,12 @@ namespace boost
|
|||||||
// unaligned big endian specialization
|
// unaligned big endian specialization
|
||||||
template <typename T, std::size_t n_bits>
|
template <typename T, std::size_t n_bits>
|
||||||
class endian< endianness::big, T, n_bits, alignment::unaligned >
|
class endian< endianness::big, T, n_bits, alignment::unaligned >
|
||||||
: cover_operators< endian< endianness::big, T, n_bits >, T >
|
// : cover_operators< endian< endianness::big, T, n_bits >, T >
|
||||||
{
|
{
|
||||||
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
|
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
|
||||||
public:
|
public:
|
||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
# if !defined(BOOST_NO_DEFAULTED_FUNCTIONS) || !defined(BOOST_ENDIANS_IN_UNIONS)
|
# ifndef BOOST_ENDIAN_NO_CTORS
|
||||||
endian() BOOST_ENDIAN_DEFAULTED
|
endian() BOOST_ENDIAN_DEFAULTED
|
||||||
endian(T val) { detail::store_big_endian<T, n_bits/8>(m_value, val); }
|
endian(T val) { detail::store_big_endian<T, n_bits/8>(m_value, val); }
|
||||||
# endif
|
# endif
|
||||||
@@ -173,12 +178,12 @@ namespace boost
|
|||||||
// unaligned little endian specialization
|
// unaligned little endian specialization
|
||||||
template <typename T, std::size_t n_bits>
|
template <typename T, std::size_t n_bits>
|
||||||
class endian< endianness::little, T, n_bits, alignment::unaligned >
|
class endian< endianness::little, T, n_bits, alignment::unaligned >
|
||||||
: cover_operators< endian< endianness::little, T, n_bits >, T >
|
// : cover_operators< endian< endianness::little, T, n_bits >, T >
|
||||||
{
|
{
|
||||||
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
|
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
|
||||||
public:
|
public:
|
||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
# if !defined(BOOST_NO_DEFAULTED_FUNCTIONS) || !defined(BOOST_ENDIANS_IN_UNIONS)
|
# ifndef BOOST_ENDIAN_NO_CTORS
|
||||||
endian() BOOST_ENDIAN_DEFAULTED
|
endian() BOOST_ENDIAN_DEFAULTED
|
||||||
endian(T val) { detail::store_little_endian<T, n_bits/8>(m_value, val); }
|
endian(T val) { detail::store_little_endian<T, n_bits/8>(m_value, val); }
|
||||||
# endif
|
# endif
|
||||||
@@ -191,12 +196,12 @@ namespace boost
|
|||||||
// unaligned native endian specialization
|
// unaligned native endian specialization
|
||||||
template <typename T, std::size_t n_bits>
|
template <typename T, std::size_t n_bits>
|
||||||
class endian< endianness::native, T, n_bits, alignment::unaligned >
|
class endian< endianness::native, T, n_bits, alignment::unaligned >
|
||||||
: cover_operators< endian< endianness::native, T, n_bits >, T >
|
// : cover_operators< endian< endianness::native, T, n_bits >, T >
|
||||||
{
|
{
|
||||||
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
|
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
|
||||||
public:
|
public:
|
||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
# if !defined(BOOST_NO_DEFAULTED_FUNCTIONS) || !defined(BOOST_ENDIANS_IN_UNIONS)
|
# ifndef BOOST_ENDIAN_NO_CTORS
|
||||||
endian() BOOST_ENDIAN_DEFAULTED
|
endian() BOOST_ENDIAN_DEFAULTED
|
||||||
# ifdef BOOST_BIG_ENDIAN
|
# ifdef BOOST_BIG_ENDIAN
|
||||||
endian(T val) { detail::store_big_endian<T, n_bits/8>(m_value, val); }
|
endian(T val) { detail::store_big_endian<T, n_bits/8>(m_value, val); }
|
||||||
@@ -221,13 +226,13 @@ namespace boost
|
|||||||
// aligned big endian specialization
|
// aligned big endian specialization
|
||||||
template <typename T, std::size_t n_bits>
|
template <typename T, std::size_t n_bits>
|
||||||
class endian< endianness::big, T, n_bits, alignment::aligned >
|
class endian< endianness::big, T, n_bits, alignment::aligned >
|
||||||
: cover_operators< endian< endianness::big, T, n_bits, alignment::aligned >, T >
|
// : cover_operators< endian< endianness::big, T, n_bits, alignment::aligned >, T >
|
||||||
{
|
{
|
||||||
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
|
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
|
||||||
BOOST_STATIC_ASSERT( sizeof(T) == n_bits/8 );
|
BOOST_STATIC_ASSERT( sizeof(T) == n_bits/8 );
|
||||||
public:
|
public:
|
||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
# if !defined(BOOST_NO_DEFAULTED_FUNCTIONS) || !defined(BOOST_ENDIANS_IN_UNIONS)
|
# ifndef BOOST_ENDIAN_NO_CTORS
|
||||||
endian() BOOST_ENDIAN_DEFAULTED
|
endian() BOOST_ENDIAN_DEFAULTED
|
||||||
# ifdef BOOST_BIG_ENDIAN
|
# ifdef BOOST_BIG_ENDIAN
|
||||||
endian(T val) : m_value(val) { }
|
endian(T val) : m_value(val) { }
|
||||||
@@ -249,13 +254,13 @@ namespace boost
|
|||||||
// aligned little endian specialization
|
// aligned little endian specialization
|
||||||
template <typename T, std::size_t n_bits>
|
template <typename T, std::size_t n_bits>
|
||||||
class endian< endianness::little, T, n_bits, alignment::aligned >
|
class endian< endianness::little, T, n_bits, alignment::aligned >
|
||||||
: cover_operators< endian< endianness::little, T, n_bits, alignment::aligned >, T >
|
// : cover_operators< endian< endianness::little, T, n_bits, alignment::aligned >, T >
|
||||||
{
|
{
|
||||||
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
|
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
|
||||||
BOOST_STATIC_ASSERT( sizeof(T) == n_bits/8 );
|
BOOST_STATIC_ASSERT( sizeof(T) == n_bits/8 );
|
||||||
public:
|
public:
|
||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
# if !defined(BOOST_NO_DEFAULTED_FUNCTIONS) || !defined(BOOST_ENDIANS_IN_UNIONS)
|
# ifndef BOOST_ENDIAN_NO_CTORS
|
||||||
endian() BOOST_ENDIAN_DEFAULTED
|
endian() BOOST_ENDIAN_DEFAULTED
|
||||||
# ifdef BOOST_BIG_ENDIAN
|
# ifdef BOOST_BIG_ENDIAN
|
||||||
endian(T val) : m_value(val) { }
|
endian(T val) : m_value(val) { }
|
||||||
|
@@ -5,6 +5,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "endian_test", "endian_test\
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "endian_in_union_test", "endian_in_union_test\endian_in_union_test.vcproj", "{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "endian_in_union_test", "endian_in_union_test\endian_in_union_test.vcproj", "{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "endian_operations_test", "endian_operations_test\endian_operations_test.vcproj", "{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Win32 = Debug|Win32
|
Debug|Win32 = Debug|Win32
|
||||||
@@ -19,6 +21,10 @@ Global
|
|||||||
{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}.Debug|Win32.Build.0 = Debug|Win32
|
{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}.Release|Win32.ActiveCfg = Release|Win32
|
{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}.Release|Win32.Build.0 = Release|Win32
|
{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}.Release|Win32.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@@ -0,0 +1,194 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="9.00"
|
||||||
|
Name="endian_in_union_test"
|
||||||
|
ProjectGUID="{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}"
|
||||||
|
RootNamespace="endian_in_union_test"
|
||||||
|
Keyword="Win32Proj"
|
||||||
|
TargetFrameworkVersion="196613"
|
||||||
|
>
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"
|
||||||
|
/>
|
||||||
|
</Platforms>
|
||||||
|
<ToolFiles>
|
||||||
|
</ToolFiles>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
ConfigurationType="1"
|
||||||
|
InheritedPropertySheets="..\common.vsprops"
|
||||||
|
CharacterSet="1"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories=""
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||||
|
MinimalRebuild="true"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="3"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="3"
|
||||||
|
DebugInformationFormat="4"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
LinkIncremental="2"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
SubSystem="1"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
|
ConfigurationType="1"
|
||||||
|
InheritedPropertySheets="..\common.vsprops"
|
||||||
|
CharacterSet="1"
|
||||||
|
WholeProgramOptimization="1"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="2"
|
||||||
|
EnableIntrinsicFunctions="true"
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||||
|
RuntimeLibrary="2"
|
||||||
|
EnableFunctionLevelLinking="true"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="3"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
LinkIncremental="1"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\endian_in_union_test.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||||
|
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||||
|
>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Resource Files"
|
||||||
|
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||||
|
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||||
|
>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
@@ -0,0 +1,194 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="9.00"
|
||||||
|
Name="endian_operations_test"
|
||||||
|
ProjectGUID="{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}"
|
||||||
|
RootNamespace="endian_operations_test"
|
||||||
|
Keyword="Win32Proj"
|
||||||
|
TargetFrameworkVersion="196613"
|
||||||
|
>
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"
|
||||||
|
/>
|
||||||
|
</Platforms>
|
||||||
|
<ToolFiles>
|
||||||
|
</ToolFiles>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
ConfigurationType="1"
|
||||||
|
InheritedPropertySheets="..\common.vsprops"
|
||||||
|
CharacterSet="1"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories=""
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||||
|
GeneratePreprocessedFile="0"
|
||||||
|
MinimalRebuild="true"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="3"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="3"
|
||||||
|
DebugInformationFormat="4"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
LinkIncremental="2"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
SubSystem="1"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
ConfigurationType="1"
|
||||||
|
InheritedPropertySheets="..\common.vsprops"
|
||||||
|
CharacterSet="1"
|
||||||
|
WholeProgramOptimization="1"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="2"
|
||||||
|
EnableIntrinsicFunctions="true"
|
||||||
|
AdditionalIncludeDirectories=""
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||||
|
RuntimeLibrary="2"
|
||||||
|
EnableFunctionLevelLinking="true"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="3"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
LinkIncremental="1"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\endian_operations_test.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||||
|
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||||
|
>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Resource Files"
|
||||||
|
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||||
|
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||||
|
>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
@@ -40,6 +40,7 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories=""
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
@@ -114,6 +115,7 @@
|
|||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="2"
|
Optimization="2"
|
||||||
EnableIntrinsicFunctions="true"
|
EnableIntrinsicFunctions="true"
|
||||||
|
AdditionalIncludeDirectories=""
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||||
RuntimeLibrary="2"
|
RuntimeLibrary="2"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
|
@@ -77,14 +77,7 @@ U foo;
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
big48_t b48;
|
|
||||||
b48 = 5;
|
|
||||||
assert(b48 == 5LL);
|
|
||||||
assert(b48 + 1 == 6LL);
|
|
||||||
big56_t b56;
|
|
||||||
b56 = 40;
|
|
||||||
assert(8 * b48 == b56);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
215
libs/integer/test/endian_operations_test.cpp
Normal file
215
libs/integer/test/endian_operations_test.cpp
Normal file
@@ -0,0 +1,215 @@
|
|||||||
|
// endian_operations_test.cpp ----------------------------------------------//
|
||||||
|
|
||||||
|
// Copyright Beman Dawes 2008
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
|
||||||
|
// See library home page at http://www.boost.org/libs/endian
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
#include <boost/integer/endian.hpp>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
# pragma warning( disable : 4244 )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace boost::integer;
|
||||||
|
|
||||||
|
template <class T1, class T2>
|
||||||
|
struct default_construct
|
||||||
|
{
|
||||||
|
static void test()
|
||||||
|
{
|
||||||
|
T1 o1;
|
||||||
|
o1 = 1; // quiet warnings
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T1, class T2>
|
||||||
|
struct construct
|
||||||
|
{
|
||||||
|
static void test()
|
||||||
|
{
|
||||||
|
T2 o2(1);
|
||||||
|
T1 o1(o2);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T1, class T2>
|
||||||
|
struct assign
|
||||||
|
{
|
||||||
|
static void test()
|
||||||
|
{
|
||||||
|
T2 o2;
|
||||||
|
o2 = 123;
|
||||||
|
T1 o1;
|
||||||
|
o1 = 02;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T1, class T2>
|
||||||
|
struct pass
|
||||||
|
{
|
||||||
|
static void test()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T1, class T2>
|
||||||
|
struct compare
|
||||||
|
{
|
||||||
|
static void test()
|
||||||
|
{
|
||||||
|
T1 o1 = 1;
|
||||||
|
T2 o2 = 2;
|
||||||
|
if (o1 == o2) return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <template<class, class> class Test, class T1>
|
||||||
|
void op_test_aux()
|
||||||
|
{
|
||||||
|
Test<T1, char>::test();
|
||||||
|
Test<T1, unsigned char>::test();
|
||||||
|
Test<T1, signed char>::test();
|
||||||
|
Test<T1, short>::test();
|
||||||
|
Test<T1, unsigned short>::test();
|
||||||
|
Test<T1, int>::test();
|
||||||
|
Test<T1, unsigned int>::test();
|
||||||
|
Test<T1, long>::test();
|
||||||
|
Test<T1, unsigned long>::test();
|
||||||
|
Test<T1, long long>::test();
|
||||||
|
Test<T1, unsigned long long>::test();
|
||||||
|
Test<T1, big8_t>::test();
|
||||||
|
Test<T1, big16_t>::test();
|
||||||
|
Test<T1, big24_t>::test();
|
||||||
|
Test<T1, big32_t>::test();
|
||||||
|
Test<T1, big40_t>::test();
|
||||||
|
Test<T1, big48_t>::test();
|
||||||
|
Test<T1, big56_t>::test();
|
||||||
|
Test<T1, big64_t>::test();
|
||||||
|
Test<T1, ubig8_t>::test();
|
||||||
|
Test<T1, ubig16_t>::test();
|
||||||
|
Test<T1, ubig24_t>::test();
|
||||||
|
Test<T1, ubig32_t>::test();
|
||||||
|
Test<T1, ubig40_t>::test();
|
||||||
|
Test<T1, ubig48_t>::test();
|
||||||
|
Test<T1, ubig56_t>::test();
|
||||||
|
Test<T1, ubig64_t>::test();
|
||||||
|
Test<T1, little8_t>::test();
|
||||||
|
Test<T1, little16_t>::test();
|
||||||
|
Test<T1, little24_t>::test();
|
||||||
|
Test<T1, little32_t>::test();
|
||||||
|
Test<T1, little40_t>::test();
|
||||||
|
Test<T1, little48_t>::test();
|
||||||
|
Test<T1, little56_t>::test();
|
||||||
|
Test<T1, little64_t>::test();
|
||||||
|
Test<T1, ulittle8_t>::test();
|
||||||
|
Test<T1, ulittle16_t>::test();
|
||||||
|
Test<T1, ulittle24_t>::test();
|
||||||
|
Test<T1, ulittle32_t>::test();
|
||||||
|
Test<T1, ulittle40_t>::test();
|
||||||
|
Test<T1, ulittle48_t>::test();
|
||||||
|
Test<T1, ulittle56_t>::test();
|
||||||
|
Test<T1, ulittle64_t>::test();
|
||||||
|
Test<T1, native8_t>::test();
|
||||||
|
Test<T1, native16_t>::test();
|
||||||
|
Test<T1, native24_t>::test();
|
||||||
|
Test<T1, native32_t>::test();
|
||||||
|
Test<T1, native40_t>::test();
|
||||||
|
Test<T1, native48_t>::test();
|
||||||
|
Test<T1, native56_t>::test();
|
||||||
|
Test<T1, native64_t>::test();
|
||||||
|
Test<T1, unative8_t>::test();
|
||||||
|
Test<T1, unative16_t>::test();
|
||||||
|
Test<T1, unative24_t>::test();
|
||||||
|
Test<T1, unative32_t>::test();
|
||||||
|
Test<T1, unative40_t>::test();
|
||||||
|
Test<T1, unative48_t>::test();
|
||||||
|
Test<T1, unative56_t>::test();
|
||||||
|
Test<T1, unative64_t>::test();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
template <template<class, class> class Test>
|
||||||
|
void op_test()
|
||||||
|
{
|
||||||
|
op_test_aux<Test, char>();
|
||||||
|
op_test_aux<Test, unsigned char>();
|
||||||
|
op_test_aux<Test, signed char>();
|
||||||
|
op_test_aux<Test, short>();
|
||||||
|
op_test_aux<Test, unsigned short>();
|
||||||
|
op_test_aux<Test, int>();
|
||||||
|
op_test_aux<Test, unsigned int>();
|
||||||
|
op_test_aux<Test, long>();
|
||||||
|
op_test_aux<Test, unsigned long>();
|
||||||
|
op_test_aux<Test, long long>();
|
||||||
|
op_test_aux<Test, unsigned long long>();
|
||||||
|
op_test_aux<Test, big8_t>();
|
||||||
|
op_test_aux<Test, big16_t>();
|
||||||
|
op_test_aux<Test, big24_t>();
|
||||||
|
op_test_aux<Test, big32_t>();
|
||||||
|
op_test_aux<Test, big40_t>();
|
||||||
|
op_test_aux<Test, big48_t>();
|
||||||
|
op_test_aux<Test, big56_t>();
|
||||||
|
op_test_aux<Test, big64_t>();
|
||||||
|
op_test_aux<Test, ubig8_t>();
|
||||||
|
op_test_aux<Test, ubig16_t>();
|
||||||
|
op_test_aux<Test, ubig24_t>();
|
||||||
|
op_test_aux<Test, ubig32_t>();
|
||||||
|
op_test_aux<Test, ubig40_t>();
|
||||||
|
op_test_aux<Test, ubig48_t>();
|
||||||
|
op_test_aux<Test, ubig56_t>();
|
||||||
|
op_test_aux<Test, ubig64_t>();
|
||||||
|
op_test_aux<Test, little8_t>();
|
||||||
|
op_test_aux<Test, little16_t>();
|
||||||
|
op_test_aux<Test, little24_t>();
|
||||||
|
op_test_aux<Test, little32_t>();
|
||||||
|
op_test_aux<Test, little40_t>();
|
||||||
|
op_test_aux<Test, little48_t>();
|
||||||
|
op_test_aux<Test, little56_t>();
|
||||||
|
op_test_aux<Test, little64_t>();
|
||||||
|
op_test_aux<Test, ulittle8_t>();
|
||||||
|
op_test_aux<Test, ulittle16_t>();
|
||||||
|
op_test_aux<Test, ulittle24_t>();
|
||||||
|
op_test_aux<Test, ulittle32_t>();
|
||||||
|
op_test_aux<Test, ulittle40_t>();
|
||||||
|
op_test_aux<Test, ulittle48_t>();
|
||||||
|
op_test_aux<Test, ulittle56_t>();
|
||||||
|
op_test_aux<Test, ulittle64_t>();
|
||||||
|
op_test_aux<Test, native8_t>();
|
||||||
|
op_test_aux<Test, native16_t>();
|
||||||
|
op_test_aux<Test, native24_t>();
|
||||||
|
op_test_aux<Test, native32_t>();
|
||||||
|
op_test_aux<Test, native40_t>();
|
||||||
|
op_test_aux<Test, native48_t>();
|
||||||
|
op_test_aux<Test, native56_t>();
|
||||||
|
op_test_aux<Test, native64_t>();
|
||||||
|
op_test_aux<Test, unative8_t>();
|
||||||
|
op_test_aux<Test, unative16_t>();
|
||||||
|
op_test_aux<Test, unative24_t>();
|
||||||
|
op_test_aux<Test, unative32_t>();
|
||||||
|
op_test_aux<Test, unative40_t>();
|
||||||
|
op_test_aux<Test, unative48_t>();
|
||||||
|
op_test_aux<Test, unative56_t>();
|
||||||
|
op_test_aux<Test, unative64_t>();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
big32_t o1(1);
|
||||||
|
big32_t o2(2L);
|
||||||
|
big32_t o3(3LL);
|
||||||
|
|
||||||
|
op_test<default_construct>();
|
||||||
|
op_test<construct>();
|
||||||
|
op_test<assign>();
|
||||||
|
op_test<pass>();
|
||||||
|
op_test<compare>();
|
||||||
|
return 0;
|
||||||
|
}
|
Reference in New Issue
Block a user