From a420669fcbedc7c516c44c03f7b45bc28395dd86 Mon Sep 17 00:00:00 2001 From: Robert Ramey Date: Tue, 15 Apr 2014 23:01:42 -0700 Subject: [PATCH] test_modulus improvements to logical/shift operations --- test/test_numeric.cpp | 250 ------------------------------ test/vcide/example_test.vcproj | 242 ----------------------------- test/vcide/safe_numerics.sln | 99 ------------ test/vcide/test_add.vcproj | 206 ------------------------ test/vcide/test_comparison.vcproj | 188 ---------------------- test/vcide/test_conversion.vcproj | 198 ----------------------- test/vcide/test_divide.vcproj | 210 ------------------------- test/vcide/test_modulus.vcproj | 206 ------------------------ test/vcide/test_multiply.vcproj | 206 ------------------------ test/vcide/test_numeric.vcproj | 202 ------------------------ test/vcide/test_subtract.vcproj | 206 ------------------------ 11 files changed, 2213 deletions(-) delete mode 100644 test/test_numeric.cpp delete mode 100644 test/vcide/example_test.vcproj delete mode 100644 test/vcide/safe_numerics.sln delete mode 100644 test/vcide/test_add.vcproj delete mode 100644 test/vcide/test_comparison.vcproj delete mode 100644 test/vcide/test_conversion.vcproj delete mode 100644 test/vcide/test_divide.vcproj delete mode 100644 test/vcide/test_modulus.vcproj delete mode 100644 test/vcide/test_multiply.vcproj delete mode 100644 test/vcide/test_numeric.vcproj delete mode 100644 test/vcide/test_subtract.vcproj diff --git a/test/test_numeric.cpp b/test/test_numeric.cpp deleted file mode 100644 index 8f4a775..0000000 --- a/test/test_numeric.cpp +++ /dev/null @@ -1,250 +0,0 @@ -// Copyright (c) 2012 Robert Ramey -// -// 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) - -#include "../include/numeric.hpp" - -//#include -#include -#include -#include -#include - -#include -#include -//#include - -BOOST_MPL_ASSERT(( boost::numeric::is_signed )); -BOOST_MPL_ASSERT_NOT(( boost::numeric::is_signed )); -BOOST_MPL_ASSERT_RELATION(8, ==, boost::numeric::bits::value); -BOOST_MPL_ASSERT_RELATION(16, ==, (boost::numeric::max_bits::value)); -BOOST_MPL_ASSERT_RELATION(16, ==, (boost::numeric::max_bits::value)); - -//////////////////////////////////////////////////////////// -// addition of various types of integers - -template -struct addition_display { - BOOST_MPL_ASSERT_RELATION(boost::numeric::bits::value, >=, B); -}; - -// note we have to break this into two separate macros to avoid -// having gcc flag a compile error -#define TEST_ADDITION1(T, U) \ - BOOST_MPL_ASSERT_RELATION( \ - (boost::integer_traits< \ - addition_result_type::type \ - >::const_max), \ - >=, \ - boost::integer_traits::const_max \ - + boost::integer_traits::const_max \ - ); \ - { \ - typedef boost::mpl::print< \ - addition_display< \ - T, \ - U, \ - addition_result_type::type, \ - addition_result_bits::value \ - > \ - >::type tdef; \ - } \ -/**/ -#define TEST_ADDITION2(T, U) \ - BOOST_MPL_ASSERT_RELATION( \ - (boost::integer_traits< \ - addition_result_type::type \ - >::const_min), \ - <=, \ - boost::integer_traits::const_min \ - + boost::integer_traits::const_min \ - ); \ - { \ - typedef boost::mpl::print< \ - addition_display< \ - T, \ - U, \ - addition_result_type::type, \ - addition_result_bits::value \ - > \ - >::type tdef; \ - } \ -/**/ - -void add(){ - using namespace boost::numeric; - TEST_ADDITION1(boost::int8_t, boost::int8_t) - TEST_ADDITION1(boost::int16_t, boost::int8_t) - TEST_ADDITION1(boost::uint8_t, boost::uint8_t) - TEST_ADDITION1(boost::uint16_t, boost::uint8_t) - TEST_ADDITION1(boost::uint16_t, boost::int8_t) - TEST_ADDITION1(boost::int16_t, boost::uint8_t) - - TEST_ADDITION2(boost::int8_t, boost::int8_t) - TEST_ADDITION2(boost::int16_t, boost::int8_t) - TEST_ADDITION2(boost::uint8_t, boost::uint8_t) - TEST_ADDITION2(boost::uint16_t, boost::uint8_t) - TEST_ADDITION2(boost::uint16_t, boost::int8_t) - TEST_ADDITION2(boost::int16_t, boost::uint8_t) -} - -//////////////////////////////////////////////////////////// -// subtraction of various types of integers - -template -struct subtraction_display {}; - -#if 1 -// note we have to break this into two separate macros to avoid -// having gcc flag a compile error -#define TEST_SUBTRACTION1(T, U) \ - BOOST_MPL_ASSERT_RELATION( \ - (boost::integer_traits< \ - subtraction_result_type::type \ - >::const_max), \ - >=, \ - boost::integer_traits::const_max \ - + boost::integer_traits::const_max \ - ); \ - { \ - typedef boost::mpl::print< \ - subtraction_display< \ - T, \ - U, \ - subtraction_result_type::type, \ - subtraction_result_bits::value \ - > \ - >::type tdef; \ - } \ -/**/ -#define TEST_SUBTRACTION2(T, U) \ - BOOST_MPL_ASSERT_RELATION( \ - (boost::integer_traits< \ - subtraction_result_type::type \ - >::const_min), \ - <=, \ - boost::integer_traits::const_min \ - + boost::integer_traits::const_min \ - ); \ - { \ - typedef boost::mpl::print< \ - subtraction_display< \ - T, \ - U, \ - subtraction_result_type::type, \ - subtraction_result_bits::value \ - > \ - >::type tdef; \ - } \ -/**/ - -void subtract(){ - using namespace boost::numeric; - TEST_SUBTRACTION1(boost::int8_t, boost::int8_t) - TEST_SUBTRACTION1(boost::int16_t, boost::int8_t) - TEST_SUBTRACTION1(boost::uint8_t, boost::uint8_t) - TEST_SUBTRACTION1(boost::uint16_t, boost::uint8_t) - TEST_SUBTRACTION1(boost::uint16_t, boost::int8_t) - TEST_SUBTRACTION1(boost::int16_t, boost::uint8_t) - - TEST_SUBTRACTION2(boost::int8_t, boost::int8_t) - TEST_SUBTRACTION2(boost::int16_t, boost::int8_t) - TEST_SUBTRACTION2(boost::uint8_t, boost::uint8_t) - TEST_SUBTRACTION2(boost::uint16_t, boost::uint8_t) - TEST_SUBTRACTION2(boost::uint16_t, boost::int8_t) - TEST_SUBTRACTION2(boost::int16_t, boost::uint8_t) -} - -#endif - -//////////////////////////////////////////////////////////// -// multiplication of various types of integers - -// note - this test is not really correct. What is really needed -// is compile time integer interval arithmetic - which we don't -// have. Addition is trivial - see above - but multiplication -// is more challanging. So, for now, this test fails to detect -// implementation errors in calculation of ranges of the result -// of multiplications - -template -struct multiply_display {}; - -#define TEST_MULTIPLICATION1(T, U) \ - BOOST_MPL_ASSERT_RELATION( \ - (boost::integer_traits< \ - multiply_result_type::type \ - >::const_max), \ - >=, \ - boost::integer_traits::const_max \ - * boost::integer_traits::const_max \ - ); \ - { \ - typedef boost::mpl::print< \ - multiply_display< \ - T, \ - U, \ - multiply_result_type::type, \ - multiply_result_bits::value \ - > \ - >::type tdef; \ - } \ -/**/ -#define TEST_MULTIPLICATION2(T, U) \ - BOOST_MPL_ASSERT_RELATION( \ - (boost::integer_traits< \ - multiply_result_type::type \ - >::const_min), \ - <=, \ - boost::integer_traits::const_min \ - * boost::integer_traits::const_min \ - ); \ - { \ - typedef boost::mpl::print< \ - multiply_display< \ - T, \ - U, \ - multiply_result_type::type, \ - multiply_result_bits::value \ - > \ - >::type tdef; \ - } \ -/**/ - -void multiply(){ - using namespace boost::numeric; - - TEST_MULTIPLICATION1(boost::int8_t, boost::int8_t) - TEST_MULTIPLICATION1(boost::int16_t, boost::int8_t) - TEST_MULTIPLICATION1(boost::uint8_t, boost::uint8_t) - TEST_MULTIPLICATION1(boost::uint16_t, boost::uint8_t) - TEST_MULTIPLICATION1(boost::uint16_t, boost::int8_t) - TEST_MULTIPLICATION1(boost::int16_t, boost::uint8_t) - - TEST_MULTIPLICATION2(boost::int8_t, boost::int8_t) - TEST_MULTIPLICATION2(boost::int16_t, boost::int8_t) - TEST_MULTIPLICATION2(boost::uint8_t, boost::uint8_t) - TEST_MULTIPLICATION2(boost::uint16_t, boost::uint8_t) - TEST_MULTIPLICATION2(boost::uint16_t, boost::int8_t) - TEST_MULTIPLICATION2(boost::int16_t, boost::uint8_t) -} - -const bool b = (boost::integer_traits::const_max > boost::integer_traits::const_max); - -#include - -int main(int argc, char * argv[]){ - std::cerr << boost::integer_traits::const_max << std::endl; - std::cerr << boost::integer_traits::const_max << std::endl; - std::cerr << - boost::integer_traits::const_max - *boost::integer_traits::const_max - << std::endl; - - add(); - subtract(); - multiply(); - return 0; -} diff --git a/test/vcide/example_test.vcproj b/test/vcide/example_test.vcproj deleted file mode 100644 index 3eec192..0000000 --- a/test/vcide/example_test.vcproj +++ /dev/null @@ -1,242 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/vcide/safe_numerics.sln b/test/vcide/safe_numerics.sln deleted file mode 100644 index f530794..0000000 --- a/test/vcide/safe_numerics.sln +++ /dev/null @@ -1,99 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_add", "test_add.vcproj", "{4393B586-DBB1-40B9-AE5D-A1D9E459ACD2}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_conversion", "test_conversion.vcproj", "{0E0D4BCF-507C-413C-9B8C-E8C972209F8B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_divide", "test_divide.vcproj", "{21DF917A-7E09-4F06-B599-0CD7E231F06E}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_modulus", "test_modulus.vcproj", "{3DE806F0-9703-4EF8-A57F-07DC922074D2}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_multiply", "test_multiply.vcproj", "{AF3D6B8E-EFF2-41C5-8FCE-9060BCD63974}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_subtract", "test_subtract.vcproj", "{B914598A-A377-4DFB-A3E7-DA1D0F3C4E37}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{06D85C87-845D-4C48-BC6F-2D2C5127AA81}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Library Headers", "Library Headers", "{98484F4D-80EE-431E-8B13-6DC167B628E1}" - ProjectSection(SolutionItems) = preProject - ..\..\include\numeric.hpp = ..\..\include\numeric.hpp - ..\..\include\overflow.hpp = ..\..\include\overflow.hpp - ..\..\include\safe_cast.hpp = ..\..\include\safe_cast.hpp - ..\..\include\safe_compare.hpp = ..\..\include\safe_compare.hpp - ..\..\include\safe_integer.hpp = ..\..\include\safe_integer.hpp - ..\..\include\safe_range.hpp = ..\..\include\safe_range.hpp - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "concept", "concept", "{95FF13B8-F33D-4F01-8E98-628666082703}" - ProjectSection(SolutionItems) = preProject - ..\..\include\concept\numeric.hpp = ..\..\include\concept\numeric.hpp - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_numeric", "test_numeric.vcproj", "{239CF7B4-DB8F-43D0-BC2B-D6FDFC0D4EDF}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Example", "Example", "{64AAA74D-6F56-4C20-9287-989918B52012}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_test", "example_test.vcproj", "{3E51E3C4-2F74-4470-8DE9-8B79D1F30FA8}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_safe_range", "test_safe_range.vcproj", "{6DBF6AE0-095C-4508-9420-FB2CD1B8BA3D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4393B586-DBB1-40B9-AE5D-A1D9E459ACD2}.Debug|Win32.ActiveCfg = Debug|Win32 - {4393B586-DBB1-40B9-AE5D-A1D9E459ACD2}.Debug|Win32.Build.0 = Debug|Win32 - {4393B586-DBB1-40B9-AE5D-A1D9E459ACD2}.Release|Win32.ActiveCfg = Release|Win32 - {4393B586-DBB1-40B9-AE5D-A1D9E459ACD2}.Release|Win32.Build.0 = Release|Win32 - {0E0D4BCF-507C-413C-9B8C-E8C972209F8B}.Debug|Win32.ActiveCfg = Debug|Win32 - {0E0D4BCF-507C-413C-9B8C-E8C972209F8B}.Debug|Win32.Build.0 = Debug|Win32 - {0E0D4BCF-507C-413C-9B8C-E8C972209F8B}.Release|Win32.ActiveCfg = Release|Win32 - {0E0D4BCF-507C-413C-9B8C-E8C972209F8B}.Release|Win32.Build.0 = Release|Win32 - {21DF917A-7E09-4F06-B599-0CD7E231F06E}.Debug|Win32.ActiveCfg = Debug|Win32 - {21DF917A-7E09-4F06-B599-0CD7E231F06E}.Debug|Win32.Build.0 = Debug|Win32 - {21DF917A-7E09-4F06-B599-0CD7E231F06E}.Release|Win32.ActiveCfg = Release|Win32 - {21DF917A-7E09-4F06-B599-0CD7E231F06E}.Release|Win32.Build.0 = Release|Win32 - {3DE806F0-9703-4EF8-A57F-07DC922074D2}.Debug|Win32.ActiveCfg = Debug|Win32 - {3DE806F0-9703-4EF8-A57F-07DC922074D2}.Debug|Win32.Build.0 = Debug|Win32 - {3DE806F0-9703-4EF8-A57F-07DC922074D2}.Release|Win32.ActiveCfg = Release|Win32 - {3DE806F0-9703-4EF8-A57F-07DC922074D2}.Release|Win32.Build.0 = Release|Win32 - {AF3D6B8E-EFF2-41C5-8FCE-9060BCD63974}.Debug|Win32.ActiveCfg = Debug|Win32 - {AF3D6B8E-EFF2-41C5-8FCE-9060BCD63974}.Debug|Win32.Build.0 = Debug|Win32 - {AF3D6B8E-EFF2-41C5-8FCE-9060BCD63974}.Release|Win32.ActiveCfg = Release|Win32 - {AF3D6B8E-EFF2-41C5-8FCE-9060BCD63974}.Release|Win32.Build.0 = Release|Win32 - {B914598A-A377-4DFB-A3E7-DA1D0F3C4E37}.Debug|Win32.ActiveCfg = Debug|Win32 - {B914598A-A377-4DFB-A3E7-DA1D0F3C4E37}.Debug|Win32.Build.0 = Debug|Win32 - {B914598A-A377-4DFB-A3E7-DA1D0F3C4E37}.Release|Win32.ActiveCfg = Release|Win32 - {B914598A-A377-4DFB-A3E7-DA1D0F3C4E37}.Release|Win32.Build.0 = Release|Win32 - {239CF7B4-DB8F-43D0-BC2B-D6FDFC0D4EDF}.Debug|Win32.ActiveCfg = Debug|Win32 - {239CF7B4-DB8F-43D0-BC2B-D6FDFC0D4EDF}.Debug|Win32.Build.0 = Debug|Win32 - {239CF7B4-DB8F-43D0-BC2B-D6FDFC0D4EDF}.Release|Win32.ActiveCfg = Release|Win32 - {239CF7B4-DB8F-43D0-BC2B-D6FDFC0D4EDF}.Release|Win32.Build.0 = Release|Win32 - {3E51E3C4-2F74-4470-8DE9-8B79D1F30FA8}.Debug|Win32.ActiveCfg = Debug|Win32 - {3E51E3C4-2F74-4470-8DE9-8B79D1F30FA8}.Debug|Win32.Build.0 = Debug|Win32 - {3E51E3C4-2F74-4470-8DE9-8B79D1F30FA8}.Release|Win32.ActiveCfg = Release|Win32 - {3E51E3C4-2F74-4470-8DE9-8B79D1F30FA8}.Release|Win32.Build.0 = Release|Win32 - {6DBF6AE0-095C-4508-9420-FB2CD1B8BA3D}.Debug|Win32.ActiveCfg = Debug|Win32 - {6DBF6AE0-095C-4508-9420-FB2CD1B8BA3D}.Debug|Win32.Build.0 = Debug|Win32 - {6DBF6AE0-095C-4508-9420-FB2CD1B8BA3D}.Release|Win32.ActiveCfg = Release|Win32 - {6DBF6AE0-095C-4508-9420-FB2CD1B8BA3D}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {0E0D4BCF-507C-413C-9B8C-E8C972209F8B} = {06D85C87-845D-4C48-BC6F-2D2C5127AA81} - {21DF917A-7E09-4F06-B599-0CD7E231F06E} = {06D85C87-845D-4C48-BC6F-2D2C5127AA81} - {3DE806F0-9703-4EF8-A57F-07DC922074D2} = {06D85C87-845D-4C48-BC6F-2D2C5127AA81} - {AF3D6B8E-EFF2-41C5-8FCE-9060BCD63974} = {06D85C87-845D-4C48-BC6F-2D2C5127AA81} - {B914598A-A377-4DFB-A3E7-DA1D0F3C4E37} = {06D85C87-845D-4C48-BC6F-2D2C5127AA81} - {4393B586-DBB1-40B9-AE5D-A1D9E459ACD2} = {06D85C87-845D-4C48-BC6F-2D2C5127AA81} - {239CF7B4-DB8F-43D0-BC2B-D6FDFC0D4EDF} = {06D85C87-845D-4C48-BC6F-2D2C5127AA81} - {6DBF6AE0-095C-4508-9420-FB2CD1B8BA3D} = {06D85C87-845D-4C48-BC6F-2D2C5127AA81} - {95FF13B8-F33D-4F01-8E98-628666082703} = {98484F4D-80EE-431E-8B13-6DC167B628E1} - {3E51E3C4-2F74-4470-8DE9-8B79D1F30FA8} = {64AAA74D-6F56-4C20-9287-989918B52012} - EndGlobalSection -EndGlobal diff --git a/test/vcide/test_add.vcproj b/test/vcide/test_add.vcproj deleted file mode 100644 index 52f84ee..0000000 --- a/test/vcide/test_add.vcproj +++ /dev/null @@ -1,206 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/vcide/test_comparison.vcproj b/test/vcide/test_comparison.vcproj deleted file mode 100644 index 5a6288f..0000000 --- a/test/vcide/test_comparison.vcproj +++ /dev/null @@ -1,188 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/vcide/test_conversion.vcproj b/test/vcide/test_conversion.vcproj deleted file mode 100644 index 8243a02..0000000 --- a/test/vcide/test_conversion.vcproj +++ /dev/null @@ -1,198 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/vcide/test_divide.vcproj b/test/vcide/test_divide.vcproj deleted file mode 100644 index 0c5e179..0000000 --- a/test/vcide/test_divide.vcproj +++ /dev/null @@ -1,210 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/vcide/test_modulus.vcproj b/test/vcide/test_modulus.vcproj deleted file mode 100644 index c6eea2e..0000000 --- a/test/vcide/test_modulus.vcproj +++ /dev/null @@ -1,206 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/vcide/test_multiply.vcproj b/test/vcide/test_multiply.vcproj deleted file mode 100644 index c2273e3..0000000 --- a/test/vcide/test_multiply.vcproj +++ /dev/null @@ -1,206 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/vcide/test_numeric.vcproj b/test/vcide/test_numeric.vcproj deleted file mode 100644 index 81acfac..0000000 --- a/test/vcide/test_numeric.vcproj +++ /dev/null @@ -1,202 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/vcide/test_subtract.vcproj b/test/vcide/test_subtract.vcproj deleted file mode 100644 index d761bc9..0000000 --- a/test/vcide/test_subtract.vcproj +++ /dev/null @@ -1,206 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -