deque.cpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // Copyright Aleksey Gurtovoy 2000-2004
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/mpl for documentation.
  8. // $Id$
  9. // $Date$
  10. // $Revision$
  11. #include <boost/mpl/deque.hpp>
  12. #include <boost/mpl/push_back.hpp>
  13. #include <boost/mpl/pop_back.hpp>
  14. #include <boost/mpl/push_front.hpp>
  15. #include <boost/mpl/pop_front.hpp>
  16. #include <boost/mpl/back.hpp>
  17. #include <boost/mpl/front.hpp>
  18. #include <boost/mpl/size.hpp>
  19. #include <boost/mpl/empty.hpp>
  20. #include <boost/mpl/aux_/test.hpp>
  21. MPL_TEST_CASE()
  22. {
  23. typedef deque<> d0;
  24. typedef deque<char> d1;
  25. typedef deque<char,long> d2;
  26. typedef deque<char,char,char,char,char,char,char,char,int> d9;
  27. MPL_ASSERT_RELATION( size<d0>::value, ==, 0 );
  28. MPL_ASSERT_RELATION( size<d1>::value, ==, 1 );
  29. MPL_ASSERT_RELATION( size<d2>::value, ==, 2 );
  30. MPL_ASSERT_RELATION( size<d9>::value, ==, 9 );
  31. MPL_ASSERT(( empty<d0> ));
  32. MPL_ASSERT_NOT(( empty<d1> ));
  33. MPL_ASSERT_NOT(( empty<d2> ));
  34. MPL_ASSERT_NOT(( empty<d9> ));
  35. MPL_ASSERT(( is_same< front<d1>::type,char > ));
  36. MPL_ASSERT(( is_same< back<d1>::type,char > ));
  37. MPL_ASSERT(( is_same< front<d2>::type,char > ));
  38. MPL_ASSERT(( is_same< back<d2>::type,long > ));
  39. MPL_ASSERT(( is_same< front<d9>::type,char > ));
  40. MPL_ASSERT(( is_same< back<d9>::type,int > ));
  41. }
  42. MPL_TEST_CASE()
  43. {
  44. typedef deque<char,long> d2;
  45. typedef begin<d2>::type i1;
  46. typedef next<i1>::type i2;
  47. typedef next<i2>::type i3;
  48. MPL_ASSERT(( is_same<deref<i1>::type,char> ));
  49. MPL_ASSERT(( is_same<deref<i2>::type,long> ));
  50. MPL_ASSERT(( is_same< i3, end<d2>::type > ));
  51. }
  52. MPL_TEST_CASE()
  53. {
  54. typedef deque<> d0;
  55. typedef push_back<d0,int>::type d1;
  56. MPL_ASSERT(( is_same< back<d1>::type,int > ));
  57. typedef push_front<d1,char>::type d2;
  58. MPL_ASSERT(( is_same< back<d2>::type,int > ));
  59. MPL_ASSERT(( is_same< front<d2>::type,char > ));
  60. typedef push_back<d2,long>::type d3;
  61. MPL_ASSERT(( is_same< back<d3>::type,long > ));
  62. }
  63. MPL_TEST_CASE()
  64. {
  65. typedef deque<> d0;
  66. typedef deque<char> d1;
  67. typedef deque<char,long> d2;
  68. typedef deque<char,char,char,char,char,char,char,char,int> d9;
  69. MPL_ASSERT_RELATION( size<d0>::value, ==, 0 );
  70. MPL_ASSERT_RELATION( size<d1>::value, ==, 1 );
  71. MPL_ASSERT_RELATION( size<d2>::value, ==, 2 );
  72. MPL_ASSERT_RELATION( size<d9>::value, ==, 9 );
  73. }