Boost logo

Boost-Commit :

From: igaztanaga_at_[hidden]
Date: 2007-11-21 11:18:29


Author: igaztanaga
Date: 2007-11-21 11:18:29 EST (Wed, 21 Nov 2007)
New Revision: 41280
URL: http://svn.boost.org/trac/boost/changeset/41280

Log:
Added offset_ptr test
Added:
   trunk/libs/interprocess/proj/vc7ide/offset_ptr_test.vcproj (contents, props changed)
   trunk/libs/interprocess/test/offset_ptr_test.cpp (contents, props changed)
Text files modified:
   trunk/libs/interprocess/proj/vc7ide/Interprocess.sln | 8 ++++++++
   trunk/libs/interprocess/test/expand_bwd_test_template.hpp | 4 ++--
   trunk/libs/interprocess/test/named_creation_template.hpp | 8 ++++----
   trunk/libs/interprocess/test/vector_test.cpp | 12 ++++++------
   4 files changed, 20 insertions(+), 12 deletions(-)

Modified: trunk/libs/interprocess/proj/vc7ide/Interprocess.sln
==============================================================================
--- trunk/libs/interprocess/proj/vc7ide/Interprocess.sln (original)
+++ trunk/libs/interprocess/proj/vc7ide/Interprocess.sln 2007-11-21 11:18:29 EST (Wed, 21 Nov 2007)
@@ -411,6 +411,10 @@
         ProjectSection(ProjectDependencies) = postProject
         EndProjectSection
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "offset_ptr_test", "offset_ptr_test.vcproj", "{5CE11C83-096A-84FE-4FA2-D3A6BA792002}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
 Global
         GlobalSection(SolutionConfiguration) = preSolution
                 Debug = Debug
@@ -831,6 +835,10 @@
                 {818C43EE-3561-F3AE-4FD7-8A2076E76A31}.Debug.Build.0 = Debug|Win32
                 {818C43EE-3561-F3AE-4FD7-8A2076E76A31}.Release.ActiveCfg = Release|Win32
                 {818C43EE-3561-F3AE-4FD7-8A2076E76A31}.Release.Build.0 = Release|Win32
+ {5CE11C83-096A-84FE-4FA2-D3A6BA792002}.Debug.ActiveCfg = Debug|Win32
+ {5CE11C83-096A-84FE-4FA2-D3A6BA792002}.Debug.Build.0 = Debug|Win32
+ {5CE11C83-096A-84FE-4FA2-D3A6BA792002}.Release.ActiveCfg = Release|Win32
+ {5CE11C83-096A-84FE-4FA2-D3A6BA792002}.Release.Build.0 = Release|Win32
         EndGlobalSection
         GlobalSection(ExtensibilityGlobals) = postSolution
         EndGlobalSection

Added: trunk/libs/interprocess/proj/vc7ide/offset_ptr_test.vcproj
==============================================================================
--- (empty file)
+++ trunk/libs/interprocess/proj/vc7ide/offset_ptr_test.vcproj 2007-11-21 11:18:29 EST (Wed, 21 Nov 2007)
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="offset_ptr_test"
+ ProjectGUID="{5CE11C83-096A-84FE-4FA2-D3A6BA792002}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../Bin/Win32/Debug"
+ IntermediateDirectory="Debug/offset_ptr_test"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../.."
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ TreatWChar_tAsBuiltInType="TRUE"
+ ForceConformanceInForLoopScope="FALSE"
+ UsePrecompiledHeader="0"
+ WarningLevel="4"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
+ OutputFile="$(OutDir)/offset_ptr_test_d.exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../stage/lib"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/offset_ptr_test.pdb"
+ SubSystem="1"
+ TargetMachine="1"
+ FixedBaseAddress="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../Bin/Win32/Release"
+ IntermediateDirectory="Release/offset_ptr_test"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../.."
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
+ RuntimeLibrary="2"
+ TreatWChar_tAsBuiltInType="TRUE"
+ ForceConformanceInForLoopScope="FALSE"
+ UsePrecompiledHeader="0"
+ WarningLevel="4"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
+ OutputFile="$(OutDir)/offset_ptr_test.exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../stage/lib"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{47BC32CF-6A73-3124-7AC5-32A56ADa7B2C}">
+ <File
+ RelativePath="..\..\test\offset_ptr_test.cpp">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>

Modified: trunk/libs/interprocess/test/expand_bwd_test_template.hpp
==============================================================================
--- trunk/libs/interprocess/test/expand_bwd_test_template.hpp (original)
+++ trunk/libs/interprocess/test/expand_bwd_test_template.hpp 2007-11-21 11:18:29 EST (Wed, 21 Nov 2007)
@@ -76,7 +76,7 @@
 
 //Function to check if both sets are equal
 template <class Vector1, class Vector2>
-bool CheckEqualVector(const Vector1 &vector1, const Vector2 &vector2)
+static bool CheckEqualVector(const Vector1 &vector1, const Vector2 &vector2)
 {
    if(vector1.size() != vector2.size())
       return false;
@@ -84,7 +84,7 @@
 }
 
 template<class Vector>
-bool CheckUninitializedIsZero(const Vector & v)
+static bool CheckUninitializedIsZero(const Vector & v)
 {
    typedef typename Vector::value_type value_type;
    typename Vector::size_type sz = v.size();

Modified: trunk/libs/interprocess/test/named_creation_template.hpp
==============================================================================
--- trunk/libs/interprocess/test/named_creation_template.hpp (original)
+++ trunk/libs/interprocess/test/named_creation_template.hpp 2007-11-21 11:18:29 EST (Wed, 21 Nov 2007)
@@ -20,7 +20,7 @@
 namespace boost { namespace interprocess { namespace test {
 
 template <class NamedResource>
-inline void create_then_open_then_open_or_create()
+static inline void create_then_open_then_open_or_create()
 {
    try{
       //Create it and open it twice
@@ -35,7 +35,7 @@
 }
 
 template <class NamedResource>
-inline void open_or_create_then_create()
+static inline void open_or_create_then_create()
 {
    //Create it with open_or_create and try to create it twice
    NamedResource nresource1(open_or_create);
@@ -48,7 +48,7 @@
 }
 
 template <class NamedResource>
-inline void dont_create_and_open()
+static inline void dont_create_and_open()
 {
    //Try to open it without creating
    try{
@@ -63,7 +63,7 @@
 }
 
 template <class NamedResource>
-void test_named_creation()
+static inline void test_named_creation()
 {
    std::cout << "create_then_open_then_open_or_create<"
                << typeid(NamedResource).name() << ">" << std::endl;

Added: trunk/libs/interprocess/test/offset_ptr_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/interprocess/test/offset_ptr_test.cpp 2007-11-21 11:18:29 EST (Wed, 21 Nov 2007)
@@ -0,0 +1,192 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2007. 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 http://www.boost.org/libs/interprocess for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/interprocess/detail/config_begin.hpp>
+#include <boost/interprocess/offset_ptr.hpp>
+#include <boost/interprocess/detail/type_traits.hpp>
+
+using namespace boost::interprocess;
+
+bool test_types_and_convertions()
+{
+ typedef offset_ptr<int> pint_t;
+ typedef offset_ptr<const int> pcint_t;
+ typedef offset_ptr<volatile int> pvint_t;
+ typedef offset_ptr<const volatile int> pcvint_t;
+
+ if(!detail::is_same<pint_t::value_type, int>::value)
+ return false;
+ if(!detail::is_same<pcint_t::value_type, const int>::value)
+ return false;
+ if(!detail::is_same<pvint_t::value_type, volatile int>::value)
+ return false;
+ if(!detail::is_same<pcvint_t::value_type, const volatile int>::value)
+ return false;
+ int dummy_int = 9;
+
+ { pint_t pint(&dummy_int); pcint_t pcint(pint);
+ if(pcint.get() != &dummy_int) return false; }
+ { pint_t pint(&dummy_int); pvint_t pvint(pint);
+ if(pvint.get() != &dummy_int) return false; }
+ { pint_t pint(&dummy_int); pcvint_t pcvint(pint);
+ if(pcvint.get() != &dummy_int) return false; }
+ { pcint_t pcint(&dummy_int); pcvint_t pcvint(pcint);
+ if(pcvint.get() != &dummy_int) return false; }
+ { pvint_t pvint(&dummy_int); pcvint_t pcvint(pvint);
+ if(pcvint.get() != &dummy_int) return false; }
+
+ pint_t pint(0);
+ pcint_t pcint(0);
+ pvint_t pvint(0);
+ pcvint_t pcvint(0);
+
+ pint = &dummy_int;
+ pcint = &dummy_int;
+ pvint = &dummy_int;
+ pcvint = &dummy_int;
+
+ { pcint = pint; if(pcint.get() != &dummy_int) return false; }
+ { pvint = pint; if(pvint.get() != &dummy_int) return false; }
+ { pcvint = pint; if(pcvint.get() != &dummy_int) return false; }
+ { pcvint = pcint; if(pcvint.get() != &dummy_int) return false; }
+ { pcvint = pvint; if(pcvint.get() != &dummy_int) return false; }
+
+ if(!pint)
+ return false;
+
+ pint = 0;
+ if(pint)
+ return false;
+
+ return true;
+}
+
+bool test_arithmetic()
+{
+ typedef offset_ptr<int> pint_t;
+ const int NumValues = 5;
+ int values[NumValues];
+
+ //Initialize p
+ pint_t p = values;
+ if(p.get() != values)
+ return false;
+
+ //Initialize p + NumValues
+ pint_t pe = &values[NumValues];
+ if(pe == p)
+ return false;
+ if(pe.get() != &values[NumValues])
+ return false;
+
+ //ptr - ptr
+ if((pe - p) != NumValues)
+ return false;
+ //ptr - integer
+ if((pe - NumValues) != p)
+ return false;
+ //ptr + integer
+ if((p + NumValues) != pe)
+ return false;
+ //integer + ptr
+ if((NumValues + p) != pe)
+ return false;
+ //indexing
+ if(pint_t(&p[NumValues]) != pe)
+ return false;
+ if(pint_t(&pe[-NumValues]) != p)
+ return false;
+
+ //ptr -= integer
+ pint_t p0 = pe;
+ p0-= NumValues;
+ if(p != p0)
+ return false;
+ //ptr += integer
+ pint_t penew = p0;
+ penew += NumValues;
+ if(penew != pe)
+ return false;
+
+ //++ptr
+ penew = p0;
+ for(int j = 0; j != NumValues; ++j, ++penew);
+ if(penew != pe)
+ return false;
+ //--ptr
+ p0 = pe;
+ for(int j = 0; j != NumValues; ++j, --p0);
+ if(p != p0)
+ return false;
+ //ptr++
+ penew = p0;
+ for(int j = 0; j != NumValues; ++j){
+ pint_t p = penew;
+ if(p != penew++)
+ return false;
+ }
+ //ptr--
+ p0 = pe;
+ for(int j = 0; j != NumValues; ++j){
+ pint_t p = p0;
+ if(p != p0--)
+ return false;
+ }
+
+ return true;
+}
+
+bool test_comparison()
+{
+ typedef offset_ptr<int> pint_t;
+ const int NumValues = 5;
+ int values[NumValues];
+
+ //Initialize p
+ pint_t p = values;
+ if(p.get() != values)
+ return false;
+
+ //Initialize p + NumValues
+ pint_t pe = &values[NumValues];
+ if(pe == p)
+ return false;
+ if(pe.get() != &values[NumValues])
+ return false;
+
+ //operators
+ if(p == pe)
+ return false;
+ if(p != p)
+ return false;
+ if(!(p < pe))
+ return false;
+ if(!(p <= pe))
+ return false;
+ if(!(pe > p))
+ return false;
+ if(!(pe >= p))
+ return false;
+
+ return true;
+}
+
+int main()
+{
+ if(!test_types_and_convertions())
+ return 1;
+ if(!test_arithmetic())
+ return 1;
+ if(!test_comparison())
+ return 1;
+ return 0;
+}
+
+#include <boost/interprocess/detail/config_end.hpp>

Modified: trunk/libs/interprocess/test/vector_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/vector_test.cpp (original)
+++ trunk/libs/interprocess/test/vector_test.cpp 2007-11-21 11:18:29 EST (Wed, 21 Nov 2007)
@@ -31,7 +31,6 @@
 #include "dummy_test_allocator.hpp"
 #include <string>
 #include "get_process_id_name.hpp"
-#include <boost/utility.hpp>
 
 using namespace boost::interprocess;
 
@@ -142,11 +141,12 @@
          }
          if(!test::CheckEqualContainers(shmvector, stdvector)) return false;
 
- typename MyShmVector::iterator it;
- typename MyShmVector::const_iterator cit = it;
-
- shmvector->erase(boost::next(shmvector->begin()));
- stdvector->erase(boost::next(stdvector->begin()));
+ typename MyShmVector::iterator shmit(shmvector->begin());
+ typename MyStdVector::iterator stdit(stdvector->begin());
+ typename MyShmVector::const_iterator cshmit = shmit;
+ ++shmit; ++stdit;
+ shmvector->erase(shmit);
+ stdvector->erase(stdit);
          if(!test::CheckEqualContainers(shmvector, stdvector)) return false;
 
          shmvector->erase(shmvector->begin());


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk