Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53819 - sandbox/monotonic/libs/monotonic/test
From: christian.schladetsch_at_[hidden]
Date: 2009-06-12 07:45:28


Author: cschladetsch
Date: 2009-06-12 07:45:28 EDT (Fri, 12 Jun 2009)
New Revision: 53819
URL: http://svn.boost.org/trac/boost/changeset/53819

Log:
refactored tests

Text files modified:
   sandbox/monotonic/libs/monotonic/test/main.cpp | 86 +++++++++++++++++++++------------------
   1 files changed, 46 insertions(+), 40 deletions(-)

Modified: sandbox/monotonic/libs/monotonic/test/main.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/main.cpp (original)
+++ sandbox/monotonic/libs/monotonic/test/main.cpp 2009-06-12 07:45:28 EDT (Fri, 12 Jun 2009)
@@ -13,6 +13,43 @@
 using namespace std;
 using namespace boost;
 
+void test_basic()
+{
+ monotonic::inline_storage<1000*sizeof(int)> storage1; // create local storage on the stack
+ monotonic::vector<int> v1(storage1); // create a vector that uses this storage
+
+ for(int i = 0; i < 100; ++i)
+ v1.push_back(i);
+
+ size_t len = storage1.remaining();
+ monotonic::vector<int> copy(v1);
+ size_t len2 = storage1.remaining();
+
+ assert(copy == v1);
+ assert(len - len2 == 100*sizeof(int));
+
+
+ // create the storage that will be used for the various monotonic containers.
+ // while it is on the stack here, it could be on the heap as well.
+ monotonic::inline_storage<1000> storage;
+
+ // create a list that uses inline, monotonically-increasing storage
+ monotonic::list<int> list(storage);
+ list.push_back(100);
+ list.push_back(400);
+ list.erase(list.begin());
+
+ // a map from the same storage
+ monotonic::map<int, float> map(storage);
+ map[42] = 3.14f;
+ assert(map[42] == 3.14f);
+
+ // a set...
+ monotonic::set<float> set(storage);
+ set.insert(3.14f);
+ set.insert(-123.f);
+}
+
 void test_copy()
 {
         monotonic::inline_storage<1000*sizeof(int)> storage;
@@ -209,7 +246,7 @@
                 }
         }
         double elapsed = timer.elapsed();
- cout << "test_list_speed[" << count << "]" << elapsed << endl;
+ //cout << "test_list_speed[" << count << "]" << elapsed << endl;
         return elapsed;
 }
 
@@ -248,6 +285,8 @@
         delete s;
 }
 
+// part of the test_map_list_realtime test.
+// this is to be like running part of a simulation.
 void test_map_list_impl_mono(size_t count, monotonic::storage_base &storage)
 {
         typedef monotonic::list<int> List;
@@ -269,6 +308,7 @@
         }
 }
 
+// same as test_map_list_impl_mono, but using std::containers
 void test_map_list_impl_std(size_t count)
 {
         typedef std::list<int> List;
@@ -296,7 +336,7 @@
 void test_map_list_realtime()
 {
         monotonic::inline_storage<1000000> storage;
- const size_t outter_loops = 100*1000;
+ const size_t outter_loops = 10*1000;
         const size_t inner_loops = 1000;
 
         boost::timer t0;
@@ -314,53 +354,19 @@
                 test_map_list_impl_std(inner_loops);
         }
         double e1 = t1.elapsed();
- cout << "test_map_list: std: " << e1 << endl;
+ cout << "test_map_list: std: " << e1 << endl;
 }
 
 int main()
 {
+ test_speed();
+ test_speed_heap();
         test_map_list_realtime();
         test_alignment();
- test_list_speed();
 
+ test_basic();
         test_copy();
         test_ctors();
- test_speed();
- test_speed_heap();
-
- monotonic::inline_storage<1000*sizeof(int)> storage1; // create local storage on the stack
- monotonic::vector<int> v1(storage1); // create a vector that uses this storage
-
- for(int i = 0; i < 100; ++i)
- v1.push_back(i);
-
- size_t len = storage1.remaining();
- monotonic::vector<int> copy(v1);
- size_t len2 = storage1.remaining();
-
- assert(copy == v1);
- assert(len - len2 == 100*sizeof(int));
-
-
- // create the storage that will be used for the various monotonic containers.
- // while it is on the stack here, it could be on the heap as well.
- monotonic::inline_storage<1000> storage;
-
- // create a list that uses inline, monotonically-increasing storage
- monotonic::list<int> list(storage);
- list.push_back(100);
- list.push_back(400);
- list.erase(list.begin());
-
- // a map from the same storage
- monotonic::map<int, float> map(storage);
- map[42] = 3.14f;
- assert(map[42] == 3.14f);
-
- // a set...
- monotonic::set<float> set(storage);
- set.insert(3.14f);
- set.insert(-123.f);
 
 }
 


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