From 221ad3c5857a551ea5fa4d767a8d044550aea021 Mon Sep 17 00:00:00 2001 From: Beman Date: Tue, 18 Nov 2014 10:05:45 -0500 Subject: [PATCH] Add use_cases.cpp --- example/use_cases.cpp | 73 ++++++++++++++++++++ test/endian_operations_test.cpp | 12 ++-- test/msvc/endian.sln | 8 +++ test/msvc/uses_cases/uses_cases.vcxproj | 88 +++++++++++++++++++++++++ 4 files changed, 175 insertions(+), 6 deletions(-) create mode 100644 example/use_cases.cpp create mode 100644 test/msvc/uses_cases/uses_cases.vcxproj diff --git a/example/use_cases.cpp b/example/use_cases.cpp new file mode 100644 index 0000000..4199dae --- /dev/null +++ b/example/use_cases.cpp @@ -0,0 +1,73 @@ +// endian/example/uses_cases.cpp -----------------------------------------------------// + +// Copyright Beman Dawes 2014 + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +//--------------------------------------------------------------------------------------// + +#define _SCL_SECURE_NO_WARNINGS + +#include + +#define BOOST_ENDIAN_LOG +#include +#include +#include +#include +#include + +// Maximize chance of name clashes for testing purposes +using namespace boost::endian; +using namespace std; + +using std::cout; +using std::endl; +//using boost::int8_t; +//using boost::uint8_t; +//using boost::int16_t; +//using boost::uint16_t; +//using boost::int32_t; +//using boost::uint32_t; +//using boost::int64_t; +//using boost::uint64_t; + +namespace +{ +} // unnamed namespace + +int cpp_main(int, char *[]) +{ + cout << "byte swap intrinsics: " BOOST_ENDIAN_INTRINSIC_MSG << endl; + + big_int32_t i1(1), i2(2), i3; + big_buf32_t b1(1), b2(2), b3; + + cout << "endian buffer tests" << endl; + cout << "compute\n"; + i3 = i1 + 5; + cout << "test\n"; + BOOST_TEST(i3 == 6); + cout << "compute\n"; + i3 = i1 + i2; + cout << "test\n"; + BOOST_TEST(i3 == 3); + + cout << "endian integer tests" << endl; + cout << "compute\n"; + b3 = b1 + 5; + cout << "test\n"; + BOOST_TEST(b3 == 6); + cout << "compute\n"; + b3 = b1 + b2; + cout << "test\n"; + BOOST_TEST(b3 == 3); + + + + + return ::boost::report_errors(); +} + +#include diff --git a/test/endian_operations_test.cpp b/test/endian_operations_test.cpp index a875882..5f6e9af 100644 --- a/test/endian_operations_test.cpp +++ b/test/endian_operations_test.cpp @@ -481,8 +481,8 @@ int cpp_main(int, char * []) // variations to detect ambiguities - u1 + 5; - u1 + 5u; + be::little_uint32_t u3 = u1 + 5; + u3 = u1 + 5u; if (u1 == 5) {} @@ -496,10 +496,10 @@ int cpp_main(int, char * []) u2 = u1 + 5u; // one more wrinkle - be::little_uint16_t u3(3); - u3 = 3; - std::clog << "\nu2 = u1 + u3\n"; - u2 = u1 + u3; + be::little_uint16_t u4(3); + u4 = 3; + std::clog << "\nu2 = u1 + u4\n"; + u2 = u1 + u4; std::clog << "\n"; be::endian_log = false; diff --git a/test/msvc/endian.sln b/test/msvc/endian.sln index 11ac095..82d0960 100644 --- a/test/msvc/endian.sln +++ b/test/msvc/endian.sln @@ -27,6 +27,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "loop_time_test", "loop_time EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "buffer_test", "buffer_test\buffer_test.vcxproj", "{BFB68CF4-EB92-4E5C-9694-A939496C5CDE}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uses_cases", "uses_cases\uses_cases.vcxproj", "{36BF451A-EAEF-4140-92E4-6EA461A26107}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -125,6 +127,12 @@ Global {BFB68CF4-EB92-4E5C-9694-A939496C5CDE}.Release|Win32.ActiveCfg = Release|Win32 {BFB68CF4-EB92-4E5C-9694-A939496C5CDE}.Release|Win32.Build.0 = Release|Win32 {BFB68CF4-EB92-4E5C-9694-A939496C5CDE}.Release|x64.ActiveCfg = Release|Win32 + {36BF451A-EAEF-4140-92E4-6EA461A26107}.Debug|Win32.ActiveCfg = Debug|Win32 + {36BF451A-EAEF-4140-92E4-6EA461A26107}.Debug|Win32.Build.0 = Debug|Win32 + {36BF451A-EAEF-4140-92E4-6EA461A26107}.Debug|x64.ActiveCfg = Debug|Win32 + {36BF451A-EAEF-4140-92E4-6EA461A26107}.Release|Win32.ActiveCfg = Release|Win32 + {36BF451A-EAEF-4140-92E4-6EA461A26107}.Release|Win32.Build.0 = Release|Win32 + {36BF451A-EAEF-4140-92E4-6EA461A26107}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/test/msvc/uses_cases/uses_cases.vcxproj b/test/msvc/uses_cases/uses_cases.vcxproj new file mode 100644 index 0000000..3d56680 --- /dev/null +++ b/test/msvc/uses_cases/uses_cases.vcxproj @@ -0,0 +1,88 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {36BF451A-EAEF-4140-92E4-6EA461A26107} + Win32Proj + uses_cases + + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + + + + + + + + + + + + + true + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file