test_serialization1.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Boost.MultiIndex test for serialization, part 1.
  2. *
  3. * Copyright 2003-2008 Joaquin M Lopez Munoz.
  4. * Distributed under the Boost Software License, Version 1.0.
  5. * (See accompanying file LICENSE_1_0.txt or copy at
  6. * http://www.boost.org/LICENSE_1_0.txt)
  7. *
  8. * See http://www.boost.org/libs/multi_index for library home page.
  9. */
  10. #include "test_serialization1.hpp"
  11. #include "test_serialization_template.hpp"
  12. #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
  13. #include <boost/multi_index/ordered_index.hpp>
  14. #include <boost/multi_index/sequenced_index.hpp>
  15. #include <boost/multi_index/random_access_index.hpp>
  16. #include <boost/multi_index/key_extractors.hpp>
  17. #include "non_std_allocator.hpp"
  18. using namespace boost::multi_index;
  19. void test_serialization1()
  20. {
  21. {
  22. typedef multi_index_container<
  23. int,
  24. indexed_by<
  25. sequenced<>,
  26. sequenced<>,
  27. random_access<>
  28. >
  29. > multi_index_t;
  30. multi_index_t m;
  31. for(int i=0;i<100;++i)m.push_back(i);
  32. m.reverse();
  33. test_serialization(m);
  34. m.clear();
  35. for(int j=50;j<100;++j)m.push_back(j);
  36. for(int k=0;k<50;++k)m.push_back(k);
  37. m.sort();
  38. test_serialization(m);
  39. }
  40. {
  41. typedef multi_index_container<
  42. int,
  43. indexed_by<
  44. random_access<>,
  45. sequenced<>,
  46. ordered_non_unique<identity<int> >
  47. >,
  48. non_std_allocator<int>
  49. > multi_index_t;
  50. multi_index_t m;
  51. for(int i=0;i<100;++i){
  52. m.push_back(i);
  53. m.push_back(i);
  54. m.push_back(i);
  55. }
  56. m.reverse();
  57. test_serialization(m);
  58. }
  59. }