Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / intrusive / test / stateful_value_traits_test.cpp
index 3e76eca..3386c7c 100644 (file)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga  2007-2012
+// (C) Copyright Ion Gaztanaga  2007-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 //    (See accompanying file LICENSE_1_0.txt or copy at
@@ -53,20 +53,20 @@ struct stateful_value_traits
 
    static const link_mode_type link_mode = normal_link;
 
-   stateful_value_traits(pointer values, node_ptr node_array)
-      :  values_(values),  node_array_(node_array)
+   stateful_value_traits(pointer vals, node_ptr node_array)
+      :  values_(vals),  node_array_(node_array)
    {}
 
-   node_ptr to_node_ptr (value_type &value)
+   node_ptr to_node_ptr (value_type &value) const
    {  return node_array_ + (&value - values_); }
 
    const_node_ptr to_node_ptr (const value_type &value) const
    {  return node_array_ + (&value - values_); }
 
-   pointer to_value_ptr(node_ptr n)
+   pointer to_value_ptr(const node_ptr &n) const
    {  return values_ + (n - node_array_); }
 
-   const_pointer to_value_ptr(const_node_ptr n) const
+   const_pointer to_value_ptr(const const_node_ptr &n) const
    {  return values_ + (n - node_array_); }
 
    pointer  values_;
@@ -123,9 +123,18 @@ int main()
       ; it != itend
       ; ++it){
       my_list.push_front(*it);
+      if(&*my_list.iterator_to(*it) != &my_list.front())
+         return 1;
       my_slist.push_front(*it);
-      my_set.insert(*it);
+      if(&*my_slist.iterator_to(*it) != &my_slist.front())
+         return 1;
+      Set::iterator sit = my_set.insert(*it).first;
+      if(&*my_set.iterator_to(*it) != &*sit)
+         return 1;
+      Uset::iterator uit = my_uset.insert(*it).first;
       my_uset.insert(*it);
+      if(&*my_uset.iterator_to(*it) != &*uit)
+         return 1;
    }
 
    //Now test lists